60872023-10-29 17:50:05IgnácZsonglőrködéscpp11Time limit exceeded 0/1001.58s7176 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<long long, long long>> a(N);
	for(int i = 0; i < N - 1; i++){
		cin >> a[i].first >> a[i].second;
	}

	sort(a.begin(), a.end());
	for(int i = N-1; i >= 0; i--){
		for(int j = i-1; j >= 0; j--){
			if(a[j].second == a[i].first){
				a[j].second = a[i].second;
				a.erase(a.begin() + i);
				break;
			} 
		}
	}

	cout << a.size();
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1684 KiB
2Accepted3ms1848 KiB
subtask20/20
3Accepted6ms2220 KiB
4Accepted1.041s4264 KiB
5Time limit exceeded1.565s4040 KiB
6Time limit exceeded1.572s4744 KiB
7Time limit exceeded1.565s5108 KiB
8Time limit exceeded1.58s5180 KiB
9Time limit exceeded1.557s5300 KiB
10Time limit exceeded1.565s5448 KiB
11Time limit exceeded1.544s5184 KiB
subtask30/35
12Accepted3ms3028 KiB
13Accepted3ms3268 KiB
14Accepted3ms3324 KiB
15Wrong answer3ms3408 KiB
16Accepted3ms3560 KiB
17Accepted3ms3660 KiB
18Accepted4ms3748 KiB
19Accepted3ms3744 KiB
20Wrong answer3ms3776 KiB
subtask40/45
21Accepted6ms4016 KiB
22Accepted652ms5816 KiB
23Time limit exceeded1.554s5628 KiB
24Time limit exceeded1.552s6292 KiB
25Time limit exceeded1.549s6572 KiB
26Time limit exceeded1.549s6632 KiB
27Time limit exceeded1.554s6700 KiB
28Time limit exceeded1.557s6924 KiB
29Time limit exceeded1.578s7176 KiB