228802026-01-15 23:23:22AkosVagyokMekk Mester munkái (50 pont)cpp17Wrong answer 7/5093ms4648 KiB
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
ifstream fin("be.in");
struct fasza {
    int kezd;
    int veg;
    int index;
    bool jart;
};
vector <fasza> t;
int n, napok;
bool comp(fasza a, fasza b) {
    return a.veg < b.veg;
}
bool compindex(fasza a, fasza b) {
    return a.kezd < b.kezd;
}
void beolvasas() {
    cin >> n >> napok;
    t.resize(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> t[i].kezd;
        cin >> t[i].veg;
        t[i].index = i;
        t[i].jart = 0;
    }
    sort(t.begin(), t.end(), comp);
    /*for (int i = 1; i <= n; i++) {
        cout << t[i].kezd << ' ' << t[i].veg << ' '<<t[i].index<< ' '<<t[i].veg-t[i].kezd<<endl;
    }*/
    //cout << endl << endl << endl;
}
vector <fasza> m1;
vector <fasza> m2;
vector<int>m1m;
vector<int>m2m;
int db1 = 1;
int db2 = 1;
void FoMain() {
    m1m.resize(n + 1);
    m2m.resize(n + 1);
    m1.push_back(t[1]);
    t[1].jart = 1;
    bool b = true;
    for (int i = 1; i <= n; i++) {
        if (!b) break;
        b = false;
        //cout << t[i].index << ' ';
        for (int j = i + 1; j <= n; j++) {
            if (t[i].veg < t[j].kezd) {
                m1.push_back(t[j]);
                i = j;
                i--;
                //cout << i << ' ' << endl;
                db1++;
                t[j].jart = 1;
                b = true;
                break;
            }
        }
    }
        int kezd = 0;
        for (int i = 1; i <= n; i++) {
            if (!t[i].jart) {
                kezd = i;
                
                break;
                
            }
        }
        /*cout << endl << endl << endl;*/
        /*for (int i = 1; i <= n; i++) {
            cout<<t[i].index << ' ' << t[i].jart<<endl;
        }*/

        /*cout << endl << endl << endl;*/
        if (kezd) {
            t[kezd].jart = 1;
            //cout << t[kezd].kezd << ' ' << t[kezd].veg<<endl<<endl<<endl;
            m2.push_back(t[kezd]);
            b = true;
            for (int i = kezd; i <= n; i++) {
                if (!b) break;
                b = false;
                //cout << i << ' ';
                for (int j = i + 1; j <= n; j++) {
                    if (t[i].veg < t[j].kezd&&!t[j].jart) {
                        b = true;
                        m2.push_back(t[j]);
                        /*cout << t[j].kezd << t[j].veg << endl;
                        cout << "seggbe orrba baszom a kurva anyadat" << endl;*/
                        i = j;
                        i--;
                        db2++;
                        t[j].jart= 1;
                        break;
                    }
                }
            }
        }
        else db2 = 0;
        
        /*cout << endl << endl << endl;
        for (int i = 1; i <= n; i++) {
            cout << t[i].index << ' ' << t[i].jart << endl;
        }

        cout << endl << endl << endl;*/
    }
int main()
{
    beolvasas();
    FoMain();
    //cout << endl;
    sort(m1.begin(), m1.end(), compindex);
    sort(m2.begin(), m2.end(), compindex);
    //cout << endl;
    cout << db2 << ' ' << db1 << endl;
    for (int i = 0; i <m2.size(); i++) {
        int a = m2[i].index;
        cout << a<<' ';
    }
    if (m2.size()) {
        cout << endl;
        for (int i = 0; i < m1.size(); i++) {
            int a = m1[i].index;
            cout << a << ' ';
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base7/50
1Accepted0/01ms500 KiB
2Wrong answer0/08ms748 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Accepted2/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Accepted3/31ms316 KiB
10Wrong answer0/12ms316 KiB
11Wrong answer0/12ms316 KiB
12Wrong answer0/22ms316 KiB
13Wrong answer0/22ms508 KiB
14Wrong answer0/22ms316 KiB
15Wrong answer0/22ms316 KiB
16Wrong answer0/31ms316 KiB
17Wrong answer0/281ms2748 KiB
18Wrong answer0/281ms2744 KiB
19Wrong answer0/481ms2740 KiB
20Wrong answer0/482ms2752 KiB
21Wrong answer0/482ms2868 KiB
22Wrong answer0/482ms3124 KiB
23Wrong answer0/493ms4648 KiB