149282025-02-07 22:44:39KateTaylorÁdám és Éva együttcpp17Wrong answer 24/5039ms1208 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int, int> pi;

int main() {
	int n, a, e, ptr = 0;
	cin >> n >> a;
	vector<pi> av(a + 1, { n + 1, n + 1 });
	for (int i = 0; i < a; i++) cin >> av[i].first >> av[i].second;
	cin >> e;
	vector<pi> ans;
	for (int i = 0; i < e; i++) {
		int beg, end;
		cin >> beg >> end;
		while (ptr < a && av[ptr].second < beg) ptr++;
		while (ptr < a && max(av[ptr].first, beg) < min(av[ptr].second, end)) {
			ans.push_back({ max(av[ptr].first, beg), min(av[ptr].second, end) });
			ptr++;
		}
		if (ptr) ptr--;
	}
	cout << ans.size() << "\n";
	for (pi p : ans) cout << p.first << " " << p.second << "\n";
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base24/50
1Accepted0/01ms508 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms364 KiB
9Wrong answer0/21ms316 KiB
10Accepted2/21ms508 KiB
11Accepted2/21ms316 KiB
12Wrong answer0/21ms316 KiB
13Accepted2/21ms532 KiB
14Accepted2/21ms512 KiB
15Accepted2/21ms316 KiB
16Accepted2/237ms1160 KiB
17Wrong answer0/337ms1020 KiB
18Wrong answer0/332ms956 KiB
19Wrong answer0/435ms948 KiB
20Wrong answer0/439ms1208 KiB
21Wrong answer0/437ms1200 KiB
22Wrong answer0/437ms1012 KiB