39732023-03-07 12:00:25tamasmarkÁdám és Éva együttcpp17Wrong answer 8/5041ms6460 KiB
// adam es eva eggyut.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>

using namespace std;

struct adat
{
    long long kezd, veg;
};

int n, i, A, E,a,b,j;
vector<pair<long long, long long>>megold;
vector<adat>eva,adam;

int main()
{
    cin >> n;
    cin >> A;
    adam.resize(A + 1);
    for (i = 1; i <= A; ++i)
    {
        cin >> adam[i].kezd >> adam[i].veg;
    }
    cin >> E;
    eva.resize(E + 1);
    for (i = 1; i <= E; ++i)
    {
        cin >> eva[i].kezd >> eva[i].veg;
    }
    i = 1;
    j = 1;
    while (i <= A && j <= E)
    {
        if (eva[i].veg <= adam[j].kezd) ++i;
        else if (adam[j].veg <= eva[i].kezd) ++j;
        else if (eva[i].kezd <= adam[j].kezd)
        {
            if (eva[i].veg >= adam[j].veg)
            {
                megold.push_back({ adam[j].kezd, adam[j].veg });
                ++j;
            }
            else
            {
                megold.push_back({ adam[j].kezd, eva[i].veg });
                ++i;
            }
        }
        else
        {
            if (eva[i].veg <= adam[j].veg)
            {
                megold.push_back({ eva[i].kezd, eva[i].veg });
                ++i;
            }
            else
            {
                megold.push_back({ eva[i].kezd, adam[j].veg });
                ++j;
            }
        }
    }
    cout << megold.size() << "\n";
    for (auto& e : megold)
    {
        cout << e.first << " " <<e.second<<"\n";
    }
    return 0;
}
/*
100
3
8 10
11 14
18 19
3
9 13
15 17
19 20

*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms1744 KiB
2Wrong answer0/03ms1916 KiB
3Accepted2/22ms1996 KiB
4Accepted2/23ms2396 KiB
5Accepted2/23ms2352 KiB
6Accepted2/23ms2564 KiB
7Wrong answer0/22ms2780 KiB
8Wrong answer0/22ms2968 KiB
9Wrong answer0/23ms3212 KiB
10Wrong answer0/23ms3320 KiB
11Wrong answer0/23ms3436 KiB
12Wrong answer0/23ms3504 KiB
13Wrong answer0/23ms3584 KiB
14Wrong answer0/23ms3592 KiB
15Wrong answer0/22ms3680 KiB
16Wrong answer0/237ms5748 KiB
17Wrong answer0/337ms5684 KiB
18Wrong answer0/334ms5636 KiB
19Wrong answer0/435ms5896 KiB
20Wrong answer0/441ms6460 KiB
21Wrong answer0/437ms6020 KiB
22Wrong answer0/437ms5728 KiB