95392024-02-22 20:05:31Vkrisztian01Ádám és Éva együttcpp17Runtime error 26/50239ms63128 KiB
#include <iostream>
#include<vector>
#include<map>

using namespace std;

vector<vector<int> > ki;

int main()
{
    int n,adam,eva,a,b,szamlalo=0;
    cin>>n;
    map<int,int> nums;
    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/03ms1812 KiB
2Accepted0/028ms11484 KiB
3Accepted2/23ms2216 KiB
4Accepted2/23ms2460 KiB
5Accepted2/23ms2640 KiB
6Accepted2/23ms2856 KiB
7Accepted2/23ms2940 KiB
8Accepted2/23ms3056 KiB
9Accepted2/23ms3176 KiB
10Accepted2/23ms3192 KiB
11Accepted2/24ms4132 KiB
12Accepted2/214ms8212 KiB
13Accepted2/228ms13068 KiB
14Accepted2/230ms13376 KiB
15Accepted2/2239ms50848 KiB
16Runtime error0/2231ms63128 KiB
17Runtime error0/3233ms63060 KiB
18Runtime error0/3224ms62856 KiB
19Runtime error0/4223ms62688 KiB
20Runtime error0/4234ms62680 KiB
21Runtime error0/4229ms62652 KiB
22Runtime error0/4229ms62644 KiB