215302026-01-13 11:57:13gkataMekk Mester munkái (50 pont)cpp17Elfogadva 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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/01ms316 KiB
2Elfogadva0/08ms316 KiB
3Elfogadva1/11ms316 KiB
4Elfogadva1/11ms316 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms316 KiB
7Elfogadva2/21ms316 KiB
8Elfogadva2/21ms316 KiB
9Elfogadva3/31ms316 KiB
10Elfogadva1/12ms316 KiB
11Elfogadva1/12ms316 KiB
12Elfogadva2/22ms508 KiB
13Elfogadva2/22ms332 KiB
14Elfogadva2/22ms316 KiB
15Elfogadva2/22ms500 KiB
16Elfogadva3/32ms412 KiB
17Elfogadva2/281ms1608 KiB
18Elfogadva2/279ms1596 KiB
19Elfogadva4/479ms1580 KiB
20Elfogadva4/481ms1592 KiB
21Elfogadva4/481ms1588 KiB
22Elfogadva4/483ms1588 KiB
23Elfogadva4/489ms2272 KiB