7972022-01-16 12:20:27Halasz 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/01ms1804 KiB
2Accepted0/02ms2572 KiB
3Accepted2/21ms1904 KiB
4Accepted2/21ms1908 KiB
5Accepted2/21ms1912 KiB
6Accepted2/21ms1916 KiB
7Accepted2/21ms1928 KiB
8Accepted2/21ms1928 KiB
9Accepted2/21ms1932 KiB
10Accepted2/21ms1940 KiB
11Accepted2/21ms1984 KiB
12Accepted2/22ms2152 KiB
13Accepted2/23ms2676 KiB
14Accepted2/23ms2676 KiB
15Accepted2/27ms5800 KiB
16Runtime error0/24ms2292 KiB
17Runtime error0/34ms2276 KiB
18Runtime error0/33ms2336 KiB
19Runtime error0/44ms2356 KiB
20Runtime error0/44ms2372 KiB
21Runtime error0/44ms2380 KiB
22Runtime error0/44ms2400 KiB