8092022-01-16 16:48:17Halasz EszterÁdám és Éva együttcpp11Runtime error 26/507ms5800 KiB
#include <iostream>
//#include <fstream>
#include <vector>

using namespace std;

//ifstream cin("adamesevaegyutt.in");
//ofstream cout("adamesevaegyutt.out");

vector<int>x;

vector<pair<int,int> >v;

int i,n,a,e,p,q,db,maxi;

int main()
{
    cin>>n;
    cin>>a;
    x.resize(n+1);
    for(i=1;i<=a;++i)
    {
        cin>>p>>q;
        x[p]++;
        x[q]--;
    }
    cin>>e;
    for(i=1;i<=e;++i)
    {
        cin>>p>>q;
        x[p]++;
        x[q]--;
    }

    for(i=1;i<=n;++i)
        x[i]+=x[i-1];

    for(i=1;i<=n;++i)
    {
        if(x[i]==2) db++;
        else if(db!=0)
        {
            v.push_back({i-db,i});
            db=0;
        }
    }
    cout<<v.size()<<"\n";
    for(auto e:v)
        cout<<e.first<<" "<<e.second<<"\n";
    return 0;

}
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/02ms1804 KiB
2Accepted0/02ms2632 KiB
3Accepted2/21ms1900 KiB
4Accepted2/21ms1912 KiB
5Accepted2/21ms1812 KiB
6Accepted2/21ms1920 KiB
7Accepted2/21ms1928 KiB
8Accepted2/21ms1936 KiB
9Accepted2/21ms1928 KiB
10Accepted2/21ms1940 KiB
11Accepted2/21ms1980 KiB
12Accepted2/22ms2152 KiB
13Accepted2/22ms2672 KiB
14Accepted2/22ms2676 KiB
15Accepted2/27ms5800 KiB
16Runtime error0/24ms2296 KiB
17Runtime error0/34ms2312 KiB
18Runtime error0/34ms2328 KiB
19Runtime error0/44ms2344 KiB
20Runtime error0/44ms2364 KiB
21Runtime error0/44ms2376 KiB
22Runtime error0/43ms2356 KiB