89632024-02-08 06:57:42BenedekMartonDinamitcpp17Wrong answer 0/5027ms18712 KiB
#include <iostream>
#include <queue>

using namespace std;

struct kave
{
    int k, v;
};

int main()
{
    int p, a, b;
    cin >> p >> a;
    kave asz[a];
    for(int i=0; i<a; i++)
    {
        cin >> asz[i].k >> asz[i].v;
    }
    cin >> b;
    kave bsz[b], x;
    for(int i=0; i<b; i++)
    {
        cin >> bsz[i].k >> bsz[i].v;
    }
    int i=0, j=0;
    queue<kave> q;
    while(i<a and j<b)
    {
        if(max(asz[i].k, bsz[j].k)<min(asz[i].v, bsz[j].v))
        {
            x.k=max(asz[i].k, bsz[j].k);
            x.v=min(asz[i].v, bsz[j].v);
            q.push(x);
        }
        if(asz[i].v<=bsz[j].v)
        {
            i++;
        }
        else
        {
            j++;
        }
    }
    if(i==a)
    {
        i--;
        while(j<b)
        {
            j++;
            if(max(asz[i].k, bsz[j].k)<min(asz[i].v, bsz[j].v))
            {
                x.k=max(asz[i].k, bsz[j].k);
                x.v=min(asz[i].v, bsz[j].v);
                q.push(x);
            }
        }
    }
    else if(j==b)
    {
        j--;
        while(i<a)
        {
            i++;
            if(max(asz[i].k, bsz[j].k)<min(asz[i].v, bsz[j].v))
            {
                x.k=max(asz[i].k, bsz[j].k);
                x.v=min(asz[i].v, bsz[j].v);
                q.push(x);
            }
        }
    }
    cout << q.size() << endl;
    while (!q.empty())
    {
        x=q.front();
        cout << x.k << " " << x.v << endl;;
        q.pop();
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1808 KiB
2Wrong answer0/04ms3556 KiB
3Wrong answer0/29ms7148 KiB
4Wrong answer0/226ms17616 KiB
5Wrong answer0/318ms13524 KiB
6Wrong answer0/323ms16608 KiB
7Wrong answer0/227ms18196 KiB
8Wrong answer0/326ms18308 KiB
9Wrong answer0/214ms10488 KiB
10Wrong answer0/28ms6484 KiB
11Wrong answer0/316ms12480 KiB
12Wrong answer0/314ms10988 KiB
13Wrong answer0/225ms18712 KiB
14Wrong answer0/318ms15184 KiB
15Wrong answer0/28ms6468 KiB
16Wrong answer0/314ms11588 KiB
17Wrong answer0/218ms14964 KiB
18Wrong answer0/313ms10712 KiB
19Wrong answer0/217ms13868 KiB
20Wrong answer0/38ms7296 KiB
21Wrong answer0/212ms10024 KiB
22Wrong answer0/34ms4628 KiB