95522024-02-22 21:12:48Vkrisztian01Ádám és Éva együttcpp11Accepted 50/5068ms16540 KiB
#include <iostream>
#include<vector>
#include<map>

using namespace std;

long long int n,m,a,b,szamlalo=0;
vector<vector<long long int> > ki;
map<long long int,long long int> seged;

int main()
{
    cin>>n;
    cin>>m;
    while(m--)
    {
        cin>>a>>b;
        seged[a]++;
        seged[b]--;
    }
    cin>>m;
    while(m--)
    {
        cin>>a>>b;
        seged[a]++;
        seged[b]--;
    }
    for(auto x:seged)
    {
        szamlalo+=x.second;
        if(szamlalo==2 && x.second>0)
        {
            ki.push_back({x.first});
            continue;
        }
        if((szamlalo==1 && x.second==-1) || (szamlalo==0 && x.second==-2))
        {
            ki.back().push_back(x.first);
            continue;
        }
    }
    cout<<ki.size()<<"\n";
    for(auto x:ki) cout<<x[0]<<" "<<x[1]<<"\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1808 KiB
2Accepted0/03ms2020 KiB
3Accepted2/23ms2216 KiB
4Accepted2/23ms2432 KiB
5Accepted2/22ms2520 KiB
6Accepted2/22ms2516 KiB
7Accepted2/22ms2660 KiB
8Accepted2/22ms2612 KiB
9Accepted2/23ms2868 KiB
10Accepted2/23ms2948 KiB
11Accepted2/23ms2952 KiB
12Accepted2/23ms2976 KiB
13Accepted2/23ms3180 KiB
14Accepted2/23ms3376 KiB
15Accepted2/23ms3456 KiB
16Accepted2/265ms15404 KiB
17Accepted3/365ms15384 KiB
18Accepted3/357ms14788 KiB
19Accepted4/461ms15344 KiB
20Accepted4/468ms16540 KiB
21Accepted4/464ms15712 KiB
22Accepted4/463ms15696 KiB