60862023-10-29 17:47:02IgnácZsonglőrködéscpp11Time limit exceeded 0/1001.6s5712 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> 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
1Accepted3ms1808 KiB
2Accepted3ms2204 KiB
subtask20/20
3Accepted7ms2508 KiB
4Time limit exceeded1.544s2616 KiB
5Time limit exceeded1.565s3376 KiB
6Time limit exceeded1.569s3540 KiB
7Time limit exceeded1.577s3812 KiB
8Time limit exceeded1.56s3968 KiB
9Time limit exceeded1.569s4240 KiB
10Time limit exceeded1.565s4464 KiB
11Time limit exceeded1.546s4632 KiB
subtask30/35
12Accepted3ms3928 KiB
13Accepted2ms4028 KiB
14Accepted3ms3996 KiB
15Wrong answer3ms4000 KiB
16Accepted4ms4244 KiB
17Accepted4ms4288 KiB
18Accepted3ms4324 KiB
19Accepted4ms4456 KiB
20Wrong answer3ms4560 KiB
subtask40/45
21Accepted7ms4596 KiB
22Accepted1.144s5364 KiB
23Time limit exceeded1.582s4880 KiB
24Time limit exceeded1.6s5200 KiB
25Time limit exceeded1.57s5440 KiB
26Time limit exceeded1.577s5408 KiB
27Time limit exceeded1.57s5620 KiB
28Time limit exceeded1.549s5576 KiB
29Time limit exceeded1.554s5712 KiB