224152026-01-15 07:50:08ProgramozoRokaÁdám és Éva együttcpp11Runtime error 26/5032ms32000 KiB
#include <iostream>
#include <vector> 

using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int p;
	cin >> p;
	vector<int> ido(p+1,0);
	vector<int> megoldas;
	int a, b;
	cin >> a;
	for (int i = 0; i < a; ++i)
	{
		int x, y;
		cin >> x >> y;
		++ido[x-1];
		--ido[y-1];
	}
	cin >> b;
	for (int i = 0; i < b; ++i)
	{
		int x, y;
		cin >> x >> y;
		++ido[x - 1];
		--ido[y - 1];
	}
	bool egyutt = false;
	int szam = 0;
	for (int i = 0; i < p; ++i)
	{
		szam += ido[i];
		if (szam == 2 and egyutt == false)
		{
			egyutt = true;
			megoldas.push_back(i + 1);
		}
		if (szam < 2 and egyutt == true)
		{
			egyutt = false;
			megoldas.push_back(i+1);
		}
	}
	if (megoldas.size() % 2 == 1) megoldas.push_back(p);
	cout << megoldas.size() / 2 << endl;
	for (int i = 0; i < megoldas.size(); i+=2) cout << megoldas[i] << " "<<megoldas[i + 1] << " "<<endl;
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/01ms316 KiB
2Accepted0/02ms820 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Accepted2/21ms368 KiB
10Accepted2/21ms500 KiB
11Accepted2/21ms316 KiB
12Accepted2/21ms564 KiB
13Accepted2/22ms832 KiB
14Accepted2/22ms820 KiB
15Accepted2/24ms2356 KiB
16Runtime error0/228ms32000 KiB
17Runtime error0/332ms32000 KiB
18Runtime error0/327ms32000 KiB
19Runtime error0/432ms32000 KiB
20Runtime error0/432ms32000 KiB
21Runtime error0/432ms32000 KiB
22Runtime error0/432ms32000 KiB