203062026-01-06 11:49:48szabelrÁdám és Éva együttcpp17Elfogadva 50/5046ms1356 KiB
// Ádám és Éva együtt.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int p;
    cin >> p;
    int a; cin >> a;
    vector<pair<int, int>> s1(a);
    for (int i = 0; i < a; i++)
    {
        int x, y;
        cin >> x >> y;
        s1[i] = { x,y };
    }
    int e; cin >> e;
    vector<pair<int, int>> s2(e);
    for (int i = 0; i < e; i++)
    {
        int x, y;
        cin >> x >> y;
        s2[i] = { x,y };
    }
    vector<pair<int, int>> res;
    int i = 0;
    int j = 0;
    while (i < s1.size() and j < s2.size())
    {
        if(s1[i].first <= s2[j].second and s2[j].first<=s1[i].second and (max(s1[i].first, s2[j].first)!=min(s1[i].second, s2[j].second)))
            res.push_back({ max(s1[i].first, s2[j].first), min(s1[i].second, s2[j].second) });
        if (s1[i].second <= s2[j].second)
            i++;
        else
            j++;
    }
    cout << res.size() << endl;
    for (auto x : res)
        cout << x.first << " " << x.second << endl;
}

// 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/01ms316 KiB
2Elfogadva0/01ms316 KiB
3Elfogadva2/21ms316 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms316 KiB
7Elfogadva2/21ms316 KiB
8Elfogadva2/21ms316 KiB
9Elfogadva2/21ms316 KiB
10Elfogadva2/21ms316 KiB
11Elfogadva2/21ms316 KiB
12Elfogadva2/21ms316 KiB
13Elfogadva2/21ms316 KiB
14Elfogadva2/21ms316 KiB
15Elfogadva2/21ms316 KiB
16Elfogadva2/243ms1156 KiB
17Elfogadva3/345ms1204 KiB
18Elfogadva3/343ms1268 KiB
19Elfogadva4/443ms1120 KiB
20Elfogadva4/443ms1348 KiB
21Elfogadva4/443ms1356 KiB
22Elfogadva4/446ms1200 KiB