85002024-01-19 12:47:55bzsofiaMekk Mester munkái (50 pont)cpp17Futási hiba 25/5090ms6712 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() || 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
base25/50
1Elfogadva0/03ms1688 KiB
2Futási hiba0/09ms2276 KiB
3Elfogadva1/13ms2420 KiB
4Elfogadva1/13ms2404 KiB
5Elfogadva2/23ms2516 KiB
6Futási hiba0/23ms2468 KiB
7Elfogadva2/23ms2504 KiB
8Futási hiba0/23ms2844 KiB
9Elfogadva3/33ms2912 KiB
10Elfogadva1/13ms3132 KiB
11Elfogadva1/13ms3304 KiB
12Elfogadva2/23ms3396 KiB
13Elfogadva2/23ms3496 KiB
14Elfogadva2/23ms3580 KiB
15Futási hiba0/24ms3804 KiB
16Futási hiba0/33ms3776 KiB
17Elfogadva2/283ms6216 KiB
18Elfogadva2/282ms6268 KiB
19Futási hiba0/482ms6440 KiB
20Futási hiba0/482ms6408 KiB
21Futási hiba0/482ms6560 KiB
22Elfogadva4/490ms6596 KiB
23Futási hiba0/482ms6712 KiB