46092023-03-30 11:45:05AblablablaÁdám és Éva együttcpp17Wrong answer 35/5041ms5324 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";
        }
    }

    cout << valaszok.size() << "\n";
    for(pii x : valaszok){
        cout << x.first << " " << x.second << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base35/50
1Accepted0/03ms1684 KiB
2Accepted0/03ms1844 KiB
3Accepted2/23ms2060 KiB
4Accepted2/23ms2272 KiB
5Accepted2/23ms2520 KiB
6Accepted2/23ms2760 KiB
7Accepted2/23ms2936 KiB
8Accepted2/22ms3060 KiB
9Accepted2/23ms3088 KiB
10Wrong answer0/22ms3024 KiB
11Accepted2/22ms3024 KiB
12Accepted2/23ms3024 KiB
13Accepted2/23ms3232 KiB
14Accepted2/23ms3184 KiB
15Accepted2/23ms3428 KiB
16Wrong answer0/239ms4992 KiB
17Accepted3/339ms4836 KiB
18Wrong answer0/335ms4836 KiB
19Accepted4/437ms4832 KiB
20Wrong answer0/441ms5048 KiB
21Wrong answer0/439ms5104 KiB
22Accepted4/439ms5324 KiB