85012024-01-19 12:49:51bzsofiaMekk Mester munkái (50 pont)cpp17Elfogadva 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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1816 KiB
2Elfogadva0/08ms2252 KiB
3Elfogadva1/13ms2216 KiB
4Elfogadva1/13ms2428 KiB
5Elfogadva2/23ms2788 KiB
6Elfogadva2/23ms2728 KiB
7Elfogadva2/23ms2860 KiB
8Elfogadva2/23ms3004 KiB
9Elfogadva3/33ms3208 KiB
10Elfogadva1/13ms3304 KiB
11Elfogadva1/13ms3548 KiB
12Elfogadva2/23ms3756 KiB
13Elfogadva2/23ms3728 KiB
14Elfogadva2/23ms3864 KiB
15Elfogadva2/23ms3952 KiB
16Elfogadva3/33ms4300 KiB
17Elfogadva2/282ms6244 KiB
18Elfogadva2/286ms6580 KiB
19Elfogadva4/482ms6524 KiB
20Elfogadva4/482ms6852 KiB
21Elfogadva4/483ms6836 KiB
22Elfogadva4/485ms6996 KiB
23Elfogadva4/492ms7876 KiB