60902023-10-29 17:57:58IgnácZsonglőrködéscpp11Wrong answer 0/1001.6s6800 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 = 0; i < N; i++){
		for(int j = i+1; j < N; 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
1Wrong answer3ms1812 KiB
2Accepted2ms2004 KiB
subtask20/20
3Accepted8ms2408 KiB
4Time limit exceeded1.554s2808 KiB
5Time limit exceeded1.557s4300 KiB
6Time limit exceeded1.521s5040 KiB
7Time limit exceeded1.549s5360 KiB
8Time limit exceeded1.569s5580 KiB
9Time limit exceeded1.559s5624 KiB
10Time limit exceeded1.562s5592 KiB
11Time limit exceeded1.544s5964 KiB
subtask30/35
12Accepted3ms3724 KiB
13Wrong answer3ms3884 KiB
14Wrong answer3ms3920 KiB
15Wrong answer3ms3924 KiB
16Wrong answer4ms3900 KiB
17Wrong answer4ms4004 KiB
18Wrong answer4ms4000 KiB
19Wrong answer4ms4096 KiB
20Wrong answer4ms3996 KiB
subtask40/45
21Accepted7ms4020 KiB
22Time limit exceeded1.6s4388 KiB
23Time limit exceeded1.574s5788 KiB
24Time limit exceeded1.536s6236 KiB
25Time limit exceeded1.577s6384 KiB
26Time limit exceeded1.554s6684 KiB
27Time limit exceeded1.557s6800 KiB
28Time limit exceeded1.565s6792 KiB
29Time limit exceeded1.559s6640 KiB