32642023-02-23 15:40:40zsomborÁdám és Éva közül legalább az egyikcpp17Accepted 40/4086ms6648 KiB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

struct str {
    int t, ae, kv;
};

int T, n, m, k;
vector <int> b(2, 0);
vector <str> v;
vector <pair <int, int>> ans;

bool r(str a, str b) {
    if (a.t < b.t) return true;
    if (a.t > b.t) return false;
    return (a.kv > b.kv ? true : false);
}

int main()
{
    cin >> T >> n;
    v.resize(2 * n);
    for (int i = 0; i < n; i++) {
        cin >> v[2 * i].t >> v[2 * i + 1].t;
        v[2 * i].ae = v[2 * i + 1].ae = 0;
        v[2 * i].kv = 1;
        v[2 * i + 1].kv = 0;
    }
    cin >> m;
    v.resize(2 * n + 2 * m);
    for (int i = n; i < n + m; i++) {
        cin >> v[2 * i].t >> v[2 * i + 1].t;
        v[2 * i].ae = v[2 * i + 1].ae = 1;
        v[2 * i].kv = 1;
        v[2 * i + 1].kv = 0;
    }
    sort(v.begin(), v.end(), r);
    for (str& s : v) {
        if (!(b[0] + b[1])) k = s.t;
        b[s.ae] = s.kv;
        if (!(b[0] + b[1])) ans.push_back({ k,s.t });
    }
    cout << ans.size() << endl;
    for (auto& p : ans) cout << p.first << " " << p.second << endl;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1876 KiB
2Accepted0/03ms2124 KiB
3Accepted2/23ms2292 KiB
4Accepted2/23ms2380 KiB
5Accepted2/23ms2384 KiB
6Accepted2/22ms2376 KiB
7Accepted2/23ms2516 KiB
8Accepted2/23ms2724 KiB
9Accepted2/23ms2980 KiB
10Accepted2/23ms3184 KiB
11Accepted2/22ms3272 KiB
12Accepted2/23ms3240 KiB
13Accepted2/23ms3240 KiB
14Accepted2/23ms3344 KiB
15Accepted2/23ms3476 KiB
16Accepted2/276ms5944 KiB
17Accepted2/271ms6092 KiB
18Accepted2/274ms6172 KiB
19Accepted2/261ms6148 KiB
20Accepted2/286ms6648 KiB
21Accepted2/276ms6384 KiB
22Accepted2/265ms6356 KiB