8462022-01-20 13:07:21zsebiÁdám és Éva együttcpp11Wrong answer 24/5037ms8688 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
base24/50
1Accepted0/02ms1744 KiB
2Accepted0/01ms1840 KiB
3Accepted2/21ms1836 KiB
4Accepted2/21ms1844 KiB
5Accepted2/21ms1840 KiB
6Accepted2/21ms1844 KiB
7Accepted2/21ms1856 KiB
8Accepted2/21ms1868 KiB
9Accepted2/21ms1856 KiB
10Wrong answer0/21ms1864 KiB
11Accepted2/21ms1864 KiB
12Accepted2/21ms1880 KiB
13Accepted2/21ms1892 KiB
14Accepted2/21ms1884 KiB
15Accepted2/21ms1880 KiB
16Wrong answer0/234ms4900 KiB
17Wrong answer0/335ms5476 KiB
18Wrong answer0/332ms5688 KiB
19Wrong answer0/434ms6360 KiB
20Wrong answer0/437ms7476 KiB
21Wrong answer0/435ms8004 KiB
22Wrong answer0/435ms8688 KiB