89422024-02-07 11:55:37BenedekMartonÁdám és Éva együttcpp17Wrong answer 7/5081ms9596 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)
        {
            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);
            }
            j++;
        }
    }
    else
    {
        j--;
        while(i<a)
        {
            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);
            }
            i++;
        }
    }
    cout << q.size() << endl;
    while (!q.empty())
    {
        x=q.front();
        cout << x.k << " " << x.v << endl;;
        q.pop();
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base7/50
1Accepted0/03ms1936 KiB
2Wrong answer0/03ms2192 KiB
3Wrong answer0/23ms2316 KiB
4Accepted2/22ms2400 KiB
5Wrong answer0/23ms2548 KiB
6Accepted2/23ms2636 KiB
7Wrong answer0/23ms2880 KiB
8Wrong answer0/23ms2968 KiB
9Wrong answer0/23ms2968 KiB
10Wrong answer0/23ms3080 KiB
11Wrong answer0/23ms3312 KiB
12Wrong answer0/23ms3408 KiB
13Wrong answer0/23ms3384 KiB
14Wrong answer0/23ms3500 KiB
15Wrong answer0/23ms3640 KiB
16Wrong answer0/259ms5080 KiB
17Wrong answer0/361ms5992 KiB
18Accepted3/354ms6680 KiB
19Wrong answer0/459ms7568 KiB
20Wrong answer0/463ms8380 KiB
21Wrong answer0/459ms8936 KiB
22Wrong answer0/481ms9596 KiB