215302026-01-13 11:57:13gkataMekk Mester munkái (50 pont)cpp17Accepted 50/5089ms2272 KiB
// mekk.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#include <algorithm>
#define ll long long;

using namespace std;

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

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

vector<adat>x;
vector<int>mekk, fiu;

int n, m, i;
int main()
{
    cin >> n >> m;
    x.resize(n + 1);

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

    sort(x.begin() + 1, x.end(), comp);
    //for (i = 1; i <= n; ++i) cout << x[i].pos << " ";

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

    cout << mekk.size() << " " << fiu.size() << endl;
    for (auto& e : mekk) cout << x[e].pos << " ";
    cout << endl;
    for (auto& e : fiu) cout << x[e].pos << " ";
}

// 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/01ms316 KiB
2Accepted0/08ms316 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Accepted3/31ms316 KiB
10Accepted1/12ms316 KiB
11Accepted1/12ms316 KiB
12Accepted2/22ms508 KiB
13Accepted2/22ms332 KiB
14Accepted2/22ms316 KiB
15Accepted2/22ms500 KiB
16Accepted3/32ms412 KiB
17Accepted2/281ms1608 KiB
18Accepted2/279ms1596 KiB
19Accepted4/479ms1580 KiB
20Accepted4/481ms1592 KiB
21Accepted4/481ms1588 KiB
22Accepted4/483ms1588 KiB
23Accepted4/489ms2272 KiB