95352024-02-22 19:52:01Vkrisztian01Á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/04ms9688 KiB
2Accepted0/06ms9972 KiB
3Accepted2/24ms10176 KiB
4Accepted2/24ms10544 KiB
5Accepted2/24ms10352 KiB
6Accepted2/24ms10404 KiB
7Accepted2/24ms10280 KiB
8Accepted2/24ms10524 KiB
9Accepted2/24ms10892 KiB
10Accepted2/24ms10960 KiB
11Accepted2/24ms11008 KiB
12Accepted2/24ms11120 KiB
13Accepted2/24ms11060 KiB
14Accepted2/26ms11340 KiB
15Accepted2/27ms11600 KiB
16Runtime error0/26ms11740 KiB
17Runtime error0/36ms11748 KiB
18Runtime error0/36ms11984 KiB
19Runtime error0/44ms11884 KiB
20Runtime error0/46ms12188 KiB
21Runtime error0/46ms12244 KiB
22Runtime error0/44ms12252 KiB