45812023-03-30 09:49:11hackemonÁdám és Éva együttcpp17Runtime error 2/50479ms64844 KiB
#include <bits/stdc++.h>
using namespace std;


int main() {
    int n;
    cin >> n;

    int a;
    cin >> a;
    queue<pair<int, int>> adam;
    for(int i = 0;i < a;i++ ) {
        int x, y;
        cin >> x >> y;
        adam.push({x, y});
    }
    int b;
    cin >> b;
    vector<pair<int, int>> eva;
    for(int i = 0;i < b;i++ ) {
        int x, y;
        cin >> x >> y;
        eva.push_back({x, y});
    }
    int i = 0;

    vector<pair<int, int>> ans;

    while(!adam.empty()) {
        auto x = adam.front();

        for(int i = 0;i < b;i++) {
            if(x.second <= eva[i].first) {
                adam.pop();
                break;
            } else if(eva[i].second >= x.second && eva[i].first <= x.first) {
                ans.push_back({x.first, x.second});
            } else if(eva[i].second >= x.second && eva[i].first >= x.first) {
                ans.push_back({eva[i].first, x.second});
            } else if(eva[i].second <= x.second && x.first <= eva[i].second) {
                ans.push_back({x.first, eva[i].second});
            }
        }

        if(i == b) break;
    }
    

    cout << ans.size() << '\n';
    for(auto x : ans) {
        cout << x.first << ' ' << x.second << '\n';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/03ms1816 KiB
2Runtime error0/0115ms64844 KiB
3Runtime error0/254ms64604 KiB
4Accepted2/23ms2476 KiB
5Runtime error0/261ms64352 KiB
6Time limit exceeded0/2446ms2692 KiB
7Runtime error0/254ms64120 KiB
8Runtime error0/257ms63880 KiB
9Runtime error0/271ms63872 KiB
10Runtime error0/265ms63636 KiB
11Runtime error0/279ms63396 KiB
12Runtime error0/289ms63376 KiB
13Runtime error0/2109ms63148 KiB
14Runtime error0/264ms63140 KiB
15Runtime error0/281ms62920 KiB
16Time limit exceeded0/2472ms4244 KiB
17Time limit exceeded0/3467ms4432 KiB
18Wrong answer0/3172ms5628 KiB
19Time limit exceeded0/4479ms4488 KiB
20Time limit exceeded0/4472ms4512 KiB
21Time limit exceeded0/4479ms4564 KiB
22Time limit exceeded0/4428ms4788 KiB