8382022-01-20 11:29:20zsebiÁdám és Éva együttcpp11Wrong answer 15/5012ms9716 KiB
#include <iostream>
#include <vector>
//#include <fstream>


#define ll long long
#define f first
#define s second

using namespace std;

//ifstream cin("adam.in");
//ofstream cout("adam.out");


vector<ll>x;
vector< pair<ll,ll> > y;

int i,n,a,b,k,l;

int main()
{
    cin>>n>>k;
    x.resize(n+1);


    for(i=1;i<=k;++i)
    {
        cin>>a>>b;
        x[a]++;
        --x[b];
    }
    cin>>l;
    y.resize(k+l);
    for(i=1;i<=l;++i)
    {
        cin>>a>>b;
        x[a]++;
        --x[b+1];
    }
    for(i=1;i<=n;++i)
    {
        x[i]+=x[i-1];
    }
    x[n]=5;
    //for(i=0;i<=n;++i)cout<<x[i];
    //int db=0;
    int db2=0;
    int db=0;
    int p=0;
    for(i=1;i<x.size();++i)
    {

         if(x[i]==2)db++;
            else if(db!=0)
            {
                db2++;
                if(db==1)
                {
                    y[p].f=i-db;
                y[p].s=i;
                }

                else
                {
                    y[p].f=i-db;
                y[p].s=i-1;
                }


                p++;
                db=0;
            }
    }
    cout<<db2<<"\n";
    for(i=0;i<db2;++i)cout<<y[i].f<<" "<<y[i].s<<"\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Accepted0/02ms1932 KiB
2Wrong answer0/04ms3368 KiB
3Partially correct1/21ms2056 KiB
4Accepted2/21ms2056 KiB
5Partially correct1/21ms2064 KiB
6Accepted2/21ms2068 KiB
7Accepted2/21ms2076 KiB
8Partially correct1/21ms2076 KiB
9Partially correct1/22ms2080 KiB
10Wrong answer0/21ms2092 KiB
11Partially correct1/21ms2168 KiB
12Partially correct1/22ms2820 KiB
13Partially correct1/23ms3468 KiB
14Partially correct1/22ms3476 KiB
15Partially correct1/212ms9716 KiB
16Runtime error0/24ms2448 KiB
17Runtime error0/33ms2456 KiB
18Runtime error0/34ms2484 KiB
19Runtime error0/44ms2448 KiB
20Runtime error0/44ms2480 KiB
21Runtime error0/44ms2544 KiB
22Runtime error0/44ms2516 KiB