60852023-10-29 17:45:38IgnácZsonglőrködéscpp11Time limit exceeded 0/1001.577s59680 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);
			} 
		}
	}

	cout << a.size();
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2004 KiB
subtask20/20
3Accepted6ms2368 KiB
4Time limit exceeded1.565s3288 KiB
5Time limit exceeded1.56s7072 KiB
6Time limit exceeded1.57s11000 KiB
7Time limit exceeded1.56s15144 KiB
8Time limit exceeded1.557s18952 KiB
9Time limit exceeded1.577s22876 KiB
10Time limit exceeded1.549s27060 KiB
11Time limit exceeded1.577s31096 KiB
subtask30/35
12Accepted3ms30492 KiB
13Wrong answer3ms30612 KiB
14Accepted3ms30824 KiB
15Wrong answer3ms31032 KiB
16Wrong answer3ms31152 KiB
17Wrong answer4ms31068 KiB
18Wrong answer3ms31184 KiB
19Wrong answer4ms31320 KiB
20Wrong answer4ms31556 KiB
subtask40/45
21Accepted7ms31928 KiB
22Time limit exceeded1.549s32776 KiB
23Time limit exceeded1.57s36700 KiB
24Time limit exceeded1.577s40340 KiB
25Time limit exceeded1.554s44352 KiB
26Time limit exceeded1.557s48108 KiB
27Time limit exceeded1.565s52080 KiB
28Time limit exceeded1.562s55844 KiB
29Time limit exceeded1.577s59680 KiB