60922023-10-29 18:04:16IgnácZsonglőrködéscpp11Time limit exceeded 0/1001.6s7040 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());
	reverse(a.begin(), a.end());
	for(int i = N-1; i >= 0; i--){
		for(int j = i-1; j >= 0; j--){
			if(a[i].second == a[j].first){
				a[i].second = a[j].second;
				a.erase(a.begin() + j);
				break;
			} 
		}
	}

	cout << a.size();
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2052 KiB
subtask20/20
3Accepted4ms2120 KiB
4Accepted1.057s4172 KiB
5Time limit exceeded1.57s4408 KiB
6Time limit exceeded1.578s5044 KiB
7Time limit exceeded1.578s5268 KiB
8Time limit exceeded1.575s5532 KiB
9Time limit exceeded1.577s5856 KiB
10Time limit exceeded1.565s5608 KiB
11Time limit exceeded1.582s5740 KiB
subtask30/35
12Accepted3ms3640 KiB
13Accepted3ms3352 KiB
14Accepted3ms3356 KiB
15Wrong answer3ms3484 KiB
16Accepted4ms3732 KiB
17Accepted4ms3804 KiB
18Accepted3ms3872 KiB
19Accepted3ms3948 KiB
20Wrong answer3ms3952 KiB
subtask40/45
21Accepted4ms4292 KiB
22Time limit exceeded1.6s4284 KiB
23Time limit exceeded1.532s5692 KiB
24Time limit exceeded1.6s6140 KiB
25Time limit exceeded1.565s6444 KiB
26Time limit exceeded1.557s6720 KiB
27Time limit exceeded1.529s7008 KiB
28Time limit exceeded1.562s7040 KiB
29Time limit exceeded1.56s7032 KiB