85012024-01-19 12:49:51bzsofiaMekk Mester munkái (50 pont)cpp17Accepted 50/5092ms7876 KiB
// Mekk.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

//ifstream fin("Mekk.in");

struct adat
{
    int kezd, veg, poz;
};

bool comp(adat a, adat b)
{
    if (a.veg == b.veg)
    {
        return a.kezd < b.kezd;
    } return a.veg < b.veg;
}

int i, n, m;
vector <int> apa, fia;

int main()
{
    cin >> n >> m;
    vector <adat> x(n + 1);

    for (i = 1; i <= n; ++i)
    {
        cin >> x[i].kezd >> x[i].veg;
        x[i].poz = i;
    }

    sort(x.begin() + 1, x.end(), comp);

    for (i = 1; i <= n; ++i)
    {
        if ((fia.empty() || x[i].kezd > x[fia.back()].veg) && (apa.empty() || x[i].kezd > x[apa.back()].veg))
        {
            if (apa.empty() || (fia.empty() || x[apa.back()].veg > x[fia.back()].veg))
            {
                apa.push_back(i);
            }
            else
            {
                fia.push_back(i);
            }
        }else if (apa.empty() || x[i].kezd > x[apa.back()].veg)
        {
            apa.push_back(i);
        }
        else if (fia.empty() || x[i].kezd > x[fia.back()].veg)
        {
            fia.push_back(i);
        }
    }

    cout << apa.size() <<" "<< fia.size() <<"\n";
    for (auto& e : apa)
    {
        cout << x[e].poz << " ";
    }cout << "\n";

    for (auto& e : fia)
    {
        cout << x[e].poz << " ";
    }

    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1816 KiB
2Accepted0/08ms2252 KiB
3Accepted1/13ms2216 KiB
4Accepted1/13ms2428 KiB
5Accepted2/23ms2788 KiB
6Accepted2/23ms2728 KiB
7Accepted2/23ms2860 KiB
8Accepted2/23ms3004 KiB
9Accepted3/33ms3208 KiB
10Accepted1/13ms3304 KiB
11Accepted1/13ms3548 KiB
12Accepted2/23ms3756 KiB
13Accepted2/23ms3728 KiB
14Accepted2/23ms3864 KiB
15Accepted2/23ms3952 KiB
16Accepted3/33ms4300 KiB
17Accepted2/282ms6244 KiB
18Accepted2/286ms6580 KiB
19Accepted4/482ms6524 KiB
20Accepted4/482ms6852 KiB
21Accepted4/483ms6836 KiB
22Accepted4/485ms6996 KiB
23Accepted4/492ms7876 KiB