46122023-03-30 11:49:00AblablablaÁdám és Éva együttcpp17Wrong answer 31/5041ms5304 KiB
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;

int main()
{
    /*ios::sync_with_stdio(false);
    cin.tie(0);*/

    int n, a;
    cin >> n >> a;

    vector<pii> adam(a, {0, 0});
    for(int i = 0; i < a; i++){
        cin >> adam[i].first >> adam[i].second;
    }

    int e;
    cin >> e;
    vector<pii> eva(e, {0, 0});
    for(int i = 0; i < e; i++){
        cin >> eva[i].first >> eva[i].second;
    }

    int adamInd = 0;
    int evaInd = 0;
    vector<pii> valaszok;
    while(adamInd < a && evaInd < e){
        if(adam[adamInd].first <= eva[evaInd].first && adam[adamInd].second > eva[evaInd].first){
            valaszok.push_back(pii(eva[evaInd].first, min(eva[evaInd].second, adam[adamInd].second)));
            if(eva[evaInd].second < adam[adamInd].second){
                //cout << "1.1\n";
                evaInd++;
            } else{
                //cout << "1.2\n";
                adamInd++;
            }
        } else if(eva[evaInd].first <= adam[adamInd].first && eva[evaInd].second > adam[adamInd].first){
            valaszok.push_back(pii(adam[adamInd].first, min(adam[adamInd].second, eva[evaInd].second)));
            if(eva[evaInd].second < adam[adamInd].second){
                evaInd++;
                //cout << "2.1\n";
            } else{
                adamInd++;
                //cout << "2.2\n";
            }
        } else if(eva[evaInd].second < adam[adamInd].first){
            evaInd++;
            //cout << "3\n";
        } else{
            adamInd++;
            //cout << "4\n";
        }
    }

    if(valaszok.size() == 0){
        cout << "-1\n";
    } else{
        cout << valaszok.size() << "\n";
        for(pii x : valaszok){
            cout << x.first << " " << x.second << "\n";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base31/50
1Accepted0/03ms1816 KiB
2Accepted0/03ms2000 KiB
3Accepted2/23ms2260 KiB
4Wrong answer0/22ms2340 KiB
5Accepted2/23ms2848 KiB
6Wrong answer0/23ms2952 KiB
7Accepted2/23ms3200 KiB
8Accepted2/23ms3184 KiB
9Accepted2/22ms3236 KiB
10Wrong answer0/23ms3292 KiB
11Accepted2/22ms3308 KiB
12Accepted2/23ms3312 KiB
13Accepted2/23ms3440 KiB
14Accepted2/23ms3508 KiB
15Accepted2/23ms3576 KiB
16Wrong answer0/237ms4908 KiB
17Accepted3/339ms4796 KiB
18Wrong answer0/335ms4796 KiB
19Accepted4/437ms4800 KiB
20Wrong answer0/441ms4756 KiB
21Wrong answer0/439ms5088 KiB
22Accepted4/439ms5304 KiB