95432024-02-22 20:57:08Vkrisztian01Ádám és Éva együttcpp17Runtime error 0/5034ms65060 KiB
#include <iostream>
#include<vector>
#include<map>

using namespace std;

int const c=100000;
int n,adam,eva,a,b,szamlalo=0;
vector<vector<int> > nums;
vector<vector<int> > ki;

int main()
{
    cin>>n;
    nums.assign(100,vector<int>(100001,0));
    cin>>adam;
    while(adam--)
    {
        cin>>a>>b;
        nums[a/c][a%(c+1)]++;
        nums[b/c][b%(c+1)]--;
    }
    cin>>adam;
    while(adam--)
    {
        cin>>a>>b;
        nums[a/c][a%(c+1)]++;
        nums[b/c][b%(c+1)]--;
    }
    for(int i=0;i*c<=n;i++)
    {
        for(int j=1;j<=c;j++)
        {
            szamlalo+=nums[i][j];
            if(szamlalo==2 && nums[i][j]>0)
            {
               ki.push_back({i*c+j});
               continue;
            }
            if((szamlalo==1 && nums[i][j]==-1) || (szamlalo==0 && nums[i][j]==-2))
            {
                ki.back().push_back(i*c+j);
                continue;
            }
        }
    }
    cout<<ki.size()<<"\n";
    for(auto x:ki) cout<<x[0]<<" "<<x[1]<<"\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/028ms65060 KiB
2Runtime error0/028ms64824 KiB
3Runtime error0/226ms64556 KiB
4Runtime error0/228ms64324 KiB
5Runtime error0/227ms64224 KiB
6Runtime error0/234ms63984 KiB
7Runtime error0/228ms63980 KiB
8Runtime error0/228ms63788 KiB
9Runtime error0/228ms63772 KiB
10Runtime error0/228ms63788 KiB
11Runtime error0/228ms63720 KiB
12Runtime error0/228ms63492 KiB
13Runtime error0/228ms63260 KiB
14Runtime error0/228ms63260 KiB
15Runtime error0/228ms63244 KiB
16Runtime error0/228ms63180 KiB
17Runtime error0/328ms63176 KiB
18Runtime error0/328ms63172 KiB
19Runtime error0/428ms63156 KiB
20Runtime error0/428ms63152 KiB
21Runtime error0/428ms63148 KiB
22Runtime error0/428ms63152 KiB