8452022-01-20 13:06:49zsebiÁdám és Éva együttcpp11Wrong answer 0/502ms1956 KiB
//#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <deque>


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

using namespace std;

ifstream cin("eva.in");
ofstream cout ("eva.out");

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


bool metszi(ll a, ll b, ll c, ll d)
{
    if (c<b && a<=d)
        return true;
    else return false;
}

int i,n,k,l,mini,maxi,db;
int main()
{
    cin>>n>>k;
    x.resize(k+1);
    for(i=0; i<k; ++i)
    {
        cin>>x[i].f>>x[i].s;
    }
cin>>l;
    y.resize(l+1);
    for(i=0; i<l; ++i)
    {
        cin>>y[i].f>>y[i].s;
    }
    //for(i=0;i<y.size();++i)cout<<y[i].f<<" "<<y[i].s<<"\n";
    db=0;
    z.resize(l+k);
    while(!x.empty()&& !y.empty())
    {
        if(metszi(x[0].f,x[0].s,y[0].f,y[0].s))
        {
            db++;
            mini=min(x[0].s,y[0].s);
            maxi=max(x[0].f,y[0].f);
            z[db].f=maxi;
            z[db].s=mini;
        }

        if(x[0].s>y[0].s)y.pop_front();
        else x.pop_front();
    }
    cout<<db<<"\n";

    for(i=1;i<=db;++i)cout<<z[i].f<<" "<<z[i].s<<"\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/02ms1860 KiB
2Wrong answer0/01ms1888 KiB
3Wrong answer0/21ms1856 KiB
4Wrong answer0/21ms1856 KiB
5Wrong answer0/21ms1852 KiB
6Wrong answer0/21ms1856 KiB
7Wrong answer0/21ms1856 KiB
8Wrong answer0/21ms1852 KiB
9Wrong answer0/21ms1852 KiB
10Wrong answer0/21ms1852 KiB
11Wrong answer0/21ms1856 KiB
12Wrong answer0/21ms1956 KiB
13Wrong answer0/21ms1856 KiB
14Wrong answer0/21ms1856 KiB
15Wrong answer0/21ms1852 KiB
16Wrong answer0/21ms1856 KiB
17Wrong answer0/31ms1856 KiB
18Wrong answer0/31ms1856 KiB
19Wrong answer0/41ms1956 KiB
20Wrong answer0/41ms1956 KiB
21Wrong answer0/41ms1856 KiB
22Wrong answer0/41ms1956 KiB