95382024-02-22 20:04:21Vkrisztian01Ádám és Éva együttcpp17Runtime error 26/5032ms62944 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[100000003];
    for(int i=0;i<=n;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/03ms2088 KiB
2Accepted0/03ms2996 KiB
3Accepted2/23ms2508 KiB
4Accepted2/22ms2588 KiB
5Accepted2/23ms2712 KiB
6Accepted2/23ms2808 KiB
7Accepted2/23ms3036 KiB
8Accepted2/23ms3144 KiB
9Accepted2/23ms3264 KiB
10Accepted2/23ms3288 KiB
11Accepted2/23ms3648 KiB
12Accepted2/23ms4164 KiB
13Accepted2/23ms4764 KiB
14Accepted2/23ms4880 KiB
15Accepted2/26ms8088 KiB
16Runtime error0/232ms62944 KiB
17Runtime error0/330ms62912 KiB
18Runtime error0/328ms62676 KiB
19Runtime error0/432ms62672 KiB
20Runtime error0/432ms62468 KiB
21Runtime error0/432ms62464 KiB
22Runtime error0/427ms62436 KiB