224472026-01-15 08:29:56AKrisztianÁdám és Éva együttcpp17Wrong answer 4/5032ms32000 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    unsigned long long int P, A, E, x, y;
    cin >> P;
    cin >> A;
    vector<unsigned long long int> a(P, -1);
    vector<unsigned long long int> e(P, -1);
    for (unsigned long long int i=0; i<A; i++)
    {
        cin >> x;
        cin >> y;
        x=x+1;
        while (x<=y)
        {
            a[x-1]=x;
            x=x+1;
        }
    }
    cin >> E;
    for (unsigned long long int i=0; i<E; i++)
    {
        cin >> x;
        cin >> y;
        x=x+1;
        while (x<=y)
        {
            e[x-1]=x;
            x=x+1;
        }
    }
    unsigned long long int j=0;
    bool r=0;
    unsigned long long int s;
    for (unsigned long long int i=0; i<P; i++)
    {

        if (a[i]==e[i] and a[i]>-1)
        {
            if (r==0)
            {
                j=j+1;
                r=1;
            }
        }
        else
        {
            if (r==1)
            {
                r=0;
            }
        }
    }
    cout << j << endl;
    r=0;
    for (unsigned long long int i=0; i<P; i++)
    {

        if (a[i]==e[i] and a[i]>-1)
        {
            if (r==0)
            {
                s=a[i]-1;
                cout << s << " ";
                r=1;
            }
            else
            {
                s=s+1;
            }
        }
        else
        {
            if (r==1)
            {
                cout << a[i-1] << endl;
                r=0;
            }
        }
    }
    if (a[P-1]==e[P-1] and a[P-1]>-1 and r==1)
    {
        cout << a[P-1];
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/02ms1844 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/21ms332 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms500 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/21ms564 KiB
12Wrong answer0/22ms1076 KiB
13Wrong answer0/22ms1844 KiB
14Wrong answer0/22ms1844 KiB
15Wrong answer0/28ms8244 KiB
16Runtime error0/227ms32000 KiB
17Runtime error0/326ms32000 KiB
18Runtime error0/332ms32000 KiB
19Runtime error0/432ms32000 KiB
20Runtime error0/432ms32000 KiB
21Runtime error0/426ms32000 KiB
22Runtime error0/430ms32000 KiB