45862023-03-30 10:17:46AGergoÁdám és Éva együttcpp17Wrong answer 4/50500ms5100 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int utolso,adamszam,evaszam;
    cin >> utolso >> adamszam;

    vector<int> ansStart;
    vector<int> ansEnd;

    int ans = 0;

    vector<int> aStart(adamszam+1);
    vector<int> aEnd(adamszam+1);

    for(int i = 0; i < adamszam; i++)
    {
        cin >> aStart[i] >> aEnd[i];
    }

    cin >> evaszam;

    vector<int> eStart(evaszam+1);
    vector<int> eEnd(evaszam+1);

    for(int i = 0; i < evaszam; i++)
    {
        cin >> eStart[i] >> eEnd[i];
    }

    int x = 0,y = 0; //x -eva index; y - adam index

    while(y < adamszam-1 && x < evaszam-1)
    {
        while(aEnd[y] <= eStart[x])
        {
            y++;
        }

        while(eEnd[x] <= aStart[y])
        {
            x++;
        }


        if(eStart[x] > aStart[y] && eStart[x] < aEnd[y])
        {
            ans++;
            if(eEnd[x] > aEnd[y])
            {
                ansStart.push_back(eStart[x]);
                ansEnd.push_back(aEnd[y]);
                y++;
            }
            else
            {
                ansStart.push_back(eStart[x]);
                ansEnd.push_back(eEnd[x]);
                x++;
            }
        }
        else if(aStart[y] > eStart[x] && aStart[y] < eEnd[x])
        {
            ans++;
            if(aEnd[y] > eEnd[x])
            {
                ansStart.push_back(aStart[y]);
                ansEnd.push_back(eEnd[x]);
                x++;
            }
            else
            {
                ansStart.push_back(aStart[y]);
                ansEnd.push_back(aEnd[y]);
                y++;
            }
        }
    }

    cout << ans << "\n";
    for(int i = 0; i < ans; i++)
    {
        cout << ansStart[i] << " " << ansEnd[i] << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/03ms1812 KiB
2Wrong answer0/03ms2060 KiB
3Wrong answer0/23ms2292 KiB
4Accepted2/22ms2476 KiB
5Wrong answer0/23ms2688 KiB
6Accepted2/23ms3040 KiB
7Wrong answer0/23ms3112 KiB
8Wrong answer0/22ms3220 KiB
9Wrong answer0/23ms3348 KiB
10Time limit exceeded0/2500ms3420 KiB
11Wrong answer0/23ms3940 KiB
12Wrong answer0/23ms3980 KiB
13Wrong answer0/23ms3864 KiB
14Wrong answer0/23ms4116 KiB
15Wrong answer0/22ms4096 KiB
16Time limit exceeded0/2500ms3552 KiB
17Wrong answer0/337ms5100 KiB
18Time limit exceeded0/3449ms3956 KiB
19Time limit exceeded0/4467ms3792 KiB
20Time limit exceeded0/4476ms3832 KiB
21Time limit exceeded0/4476ms4732 KiB
22Time limit exceeded0/4472ms3628 KiB