60912023-10-29 18:02:17IgnácZsonglőrködéscpp11Time limit exceeded 0/1001.582s7068 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() + i);
				break;
			} 
		}
	}

	cout << a.size();
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2000 KiB
subtask20/20
3Accepted6ms2248 KiB
4Accepted1.031s4300 KiB
5Time limit exceeded1.562s4336 KiB
6Time limit exceeded1.546s4944 KiB
7Time limit exceeded1.57s5384 KiB
8Time limit exceeded1.582s5552 KiB
9Time limit exceeded1.57s5864 KiB
10Time limit exceeded1.569s5988 KiB
11Time limit exceeded1.552s6016 KiB
subtask30/35
12Accepted2ms3720 KiB
13Wrong answer2ms3684 KiB
14Wrong answer3ms3696 KiB
15Wrong answer3ms3936 KiB
16Wrong answer3ms3948 KiB
17Wrong answer3ms4076 KiB
18Wrong answer3ms4288 KiB
19Wrong answer3ms4360 KiB
20Wrong answer3ms4328 KiB
subtask40/45
21Accepted4ms4348 KiB
22Wrong answer850ms6400 KiB
23Time limit exceeded1.549s6276 KiB
24Time limit exceeded1.557s6736 KiB
25Time limit exceeded1.577s6964 KiB
26Time limit exceeded1.56s7068 KiB
27Time limit exceeded1.577s6888 KiB
28Time limit exceeded1.562s6936 KiB
29Time limit exceeded1.565s6924 KiB