95372024-02-22 20:02:51Vkrisztian01Ádám és Éva együttcpp17Runtime error 26/506ms12320 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[1000005];
    for(int i=0;i<=1000000;i++) nums[i]=0;
    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;
        }
    }
    delete nums;
    cout<<ki.size()<<"\n";
    for(auto x:ki) cout<<x[0]<<" "<<x[1]<<"\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/06ms9280 KiB
2Accepted0/06ms9572 KiB
3Accepted2/24ms9916 KiB
4Accepted2/24ms9864 KiB
5Accepted2/24ms10228 KiB
6Accepted2/26ms10296 KiB
7Accepted2/26ms10660 KiB
8Accepted2/26ms10940 KiB
9Accepted2/26ms11120 KiB
10Accepted2/24ms11264 KiB
11Accepted2/26ms11252 KiB
12Accepted2/26ms11264 KiB
13Accepted2/26ms11180 KiB
14Accepted2/26ms11432 KiB
15Accepted2/26ms11484 KiB
16Runtime error0/26ms12028 KiB
17Runtime error0/36ms12112 KiB
18Runtime error0/36ms11960 KiB
19Runtime error0/46ms12284 KiB
20Runtime error0/44ms12240 KiB
21Runtime error0/46ms12320 KiB
22Runtime error0/44ms12240 KiB