41312023-03-15 11:12:50horvathabelÁdám és Éva együttcpp17Accepted 50/50379ms29244 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int p,a;
	cin>>p>>a;
	vector<bool> talalka(p);
	for (int i=0; i<a;i++){
		int x,y;
		cin>>x>>y;
		for (int i=x; i<y;i++){
			talalka[i]=true; 
		}
	}
	int e;
	cin>>e;
	vector<pair<int,int>> ans; 
	for (int i=0; i<e;i++){
		int x,y;
		cin>>x>>y;
		for (int i=x;i<y;i++){
			if (talalka[i]){
				int k=i; 
				while (talalka[i] && i<y){
					i++;
				}
				ans.push_back(make_pair(k,i));
			}
		}
	}
	cout<<ans.size()<<endl;
	for (auto x:ans) cout<<x.first<<" "<<x.second<<endl; 
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2068 KiB
3Accepted2/23ms2236 KiB
4Accepted2/23ms2432 KiB
5Accepted2/23ms2640 KiB
6Accepted2/23ms2888 KiB
7Accepted2/22ms2932 KiB
8Accepted2/23ms3064 KiB
9Accepted2/22ms3176 KiB
10Accepted2/23ms3396 KiB
11Accepted2/23ms3456 KiB
12Accepted2/23ms3596 KiB
13Accepted2/23ms3712 KiB
14Accepted2/23ms3812 KiB
15Accepted2/24ms3968 KiB
16Accepted2/2351ms28864 KiB
17Accepted3/3379ms29244 KiB
18Accepted3/3317ms26744 KiB
19Accepted4/4340ms27868 KiB
20Accepted4/4331ms28868 KiB
21Accepted4/4354ms29116 KiB
22Accepted4/4372ms29152 KiB