95362024-02-22 19:52:53Vkrisztian01Ádám és Éva együttcpp17Runtime error 26/507ms12252 KiB
#include <iostream>
#include<vector>

using namespace std;

vector<vector<int> > ki;

int main()
{
    int n,adam,eva,a,b,szamlalo=0;
    cin>>n;
    int* nums=new int[1000002];
    for(int i=0;i<=1000000;i++) nums[i]=0;
    //cout<<nums[1000000];
    cin>>adam;
    while(adam--)
    {
        cin>>a>>b;
        ++nums[a];
        --nums[b];
    }
    cin>>eva;
    while(eva--)
    {
        cin>>a>>b;
        ++nums[a];
        --nums[b];
    }
    for(int i=1;i<=n;i++)
    {
        szamlalo+=nums[i];
        if(szamlalo==2 && nums[i]>0)
        {
            ki.push_back({i});
            continue;
        }
        if((szamlalo==1 && nums[i]==-1) || (szamlalo==0 && nums[i]==-2))
        {
            ki.back().push_back(i);
            continue;
        }
    }
    cout<<ki.size()<<"\n";
    for(auto x:ki) cout<<x[0]<<" "<<x[1]<<"\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/04ms9560 KiB
2Accepted0/06ms9848 KiB
3Accepted2/26ms9800 KiB
4Accepted2/24ms10056 KiB
5Accepted2/24ms10272 KiB
6Accepted2/26ms10448 KiB
7Accepted2/26ms10736 KiB
8Accepted2/26ms10868 KiB
9Accepted2/24ms11160 KiB
10Accepted2/24ms11516 KiB
11Accepted2/26ms11368 KiB
12Accepted2/26ms11380 KiB
13Accepted2/26ms11372 KiB
14Accepted2/26ms11516 KiB
15Accepted2/27ms11796 KiB
16Runtime error0/24ms12112 KiB
17Runtime error0/37ms12252 KiB
18Runtime error0/36ms12212 KiB
19Runtime error0/44ms12204 KiB
20Runtime error0/44ms12208 KiB
21Runtime error0/46ms12208 KiB
22Runtime error0/46ms12208 KiB