39752023-03-07 12:06:20tamasmarkÁdám és Éva együttcpp17Elfogadva 50/5041ms6724 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 >> E;
    eva.resize(E + 1);
    for (i = 1; i <= E; ++i)
    {
        cin >> eva[i].kezd >> eva[i].veg;
    }
    cin >> A;
    adam.resize(A + 1);
    for (i = 1; i <= A; ++i)
    {
        cin >> adam[i].kezd >> adam[i].veg;
    }
    i = 1;
    j = 1;
    while (i <= E && j <= A)
    {
        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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1876 KiB
2Elfogadva0/03ms2120 KiB
3Elfogadva2/22ms2148 KiB
4Elfogadva2/23ms2276 KiB
5Elfogadva2/23ms2524 KiB
6Elfogadva2/23ms2780 KiB
7Elfogadva2/23ms2952 KiB
8Elfogadva2/22ms3164 KiB
9Elfogadva2/23ms3376 KiB
10Elfogadva2/23ms3460 KiB
11Elfogadva2/23ms3836 KiB
12Elfogadva2/23ms3780 KiB
13Elfogadva2/22ms3776 KiB
14Elfogadva2/22ms3800 KiB
15Elfogadva2/23ms3904 KiB
16Elfogadva2/239ms6200 KiB
17Elfogadva3/339ms6252 KiB
18Elfogadva3/335ms6332 KiB
19Elfogadva4/437ms6724 KiB
20Elfogadva4/441ms6696 KiB
21Elfogadva4/439ms6596 KiB
22Elfogadva4/439ms6676 KiB