13282022-05-14 11:17:05nkdorka1212Ádám és Éva együttcpp11Time limit exceeded 26/50462ms55888 KiB
#include <bits/stdc++.h>

using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int p;
    cin>>p;
    vector<bool>adam(p+1,0);
    vector<bool>eva(p+1,0);
    int a;
    cin>>a;
    for(int i=1;i<=a;i++)
    {
        int l,r;
        cin>>l>>r;
        for(int i=l;i<=r-1;i++)
        {
            adam[i]=true;
        }
    }
    int e;
    cin>>e;
    for(int i=1;i<=e;i++)
    {
        int l,r;
        cin>>l>>r;
        for(int i=l;i<=r-1;i++)
        {
            eva[i]=true;
        }
    }
    vector<pair<int,int>>mo;
    int cnt=0;
    for(int i=1;i<=p;i++)
    {
        if(adam[i]==1 && eva[i]==1)
        {
            int k=i;
            i++;
            while(adam[i]==1 && eva[i]==1)
            {
                i++;
            }
            mo.push_back({k,i});
        }
    }
    cout<<mo.size()<<'\n';
    for(auto x:mo)
    {
        cout<<x.first<<" "<<x.second<<'\n';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/02ms1868 KiB
2Accepted0/02ms1864 KiB
3Accepted2/21ms1920 KiB
4Accepted2/21ms1924 KiB
5Accepted2/21ms1944 KiB
6Accepted2/21ms1948 KiB
7Accepted2/21ms1940 KiB
8Accepted2/21ms1940 KiB
9Accepted2/21ms1948 KiB
10Accepted2/21ms1964 KiB
11Accepted2/21ms1964 KiB
12Accepted2/22ms1980 KiB
13Accepted2/22ms1996 KiB
14Accepted2/22ms1988 KiB
15Accepted2/23ms2100 KiB
16Time limit exceeded0/2446ms26644 KiB
17Time limit exceeded0/3453ms27216 KiB
18Time limit exceeded0/3421ms48372 KiB
19Time limit exceeded0/4444ms51528 KiB
20Time limit exceeded0/4451ms54080 KiB
21Time limit exceeded0/4425ms29836 KiB
22Time limit exceeded0/4462ms55888 KiB