27862023-01-24 20:07:18bzsofiaÁdám és Éva együttcpp11Accepted 50/5039ms5472 KiB
#include <iostream>
#include <vector>

using namespace std;

struct adat
{
    int kezd, veg;
};

int i, j, eva, adam, n;
vector <pair <int, int>> idopont;

int main()
{
    cin>>n;

    cin>>eva;
    vector <adat> e(eva+1);
    for (i=1; i<=eva; ++i)
    {
        cin>>e[i].kezd>>e[i].veg;
    }

    cin>>adam;
    vector <adat> a(adam+1);
    for(i=1; i<=adam; ++i)
    {
        cin>>a[i].kezd>>a[i].veg;
    }

    i=1;
    j=1;
    while (i<=eva && j<=adam)
    {
        if (e[i].veg<=a[j].kezd) ++i;
        else if (a[j].veg<=e[i].kezd) ++j;
        else if (e[i].kezd<=a[j].kezd)
        {
            if (e[i].veg>=a[j].veg)
            {
                idopont.push_back({a[j].kezd, a[j].veg});
                ++j;
            }else
            {
                idopont.push_back({a[j].kezd, e[i].veg});
                ++i;
            }
        }else
        {
            if (e[i].veg<=a[j].veg)
            {
                idopont.push_back({e[i].kezd, e[i].veg});
                ++i;
            }else
            {
                idopont.push_back({e[i].kezd, a[j].veg});
                ++j;
            }
        }
    }

    cout<<idopont.size()<<"\n";
    for (auto &e:idopont)
    {
        cout<<e.first<<" "<<e.second<<"\n";
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1808 KiB
2Accepted0/02ms2008 KiB
3Accepted2/22ms2212 KiB
4Accepted2/22ms2320 KiB
5Accepted2/22ms2284 KiB
6Accepted2/22ms2532 KiB
7Accepted2/22ms2616 KiB
8Accepted2/22ms2824 KiB
9Accepted2/22ms2900 KiB
10Accepted2/22ms2896 KiB
11Accepted2/22ms3028 KiB
12Accepted2/22ms3276 KiB
13Accepted2/22ms3476 KiB
14Accepted2/22ms3700 KiB
15Accepted2/22ms3764 KiB
16Accepted2/237ms5064 KiB
17Accepted3/337ms4956 KiB
18Accepted3/334ms5080 KiB
19Accepted4/435ms5160 KiB
20Accepted4/439ms5172 KiB
21Accepted4/437ms5216 KiB
22Accepted4/437ms5472 KiB