60892023-10-29 17:52:11IgnácZsonglőrködéscpp11Wrong answer 0/1001.577s7172 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 = 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
1Wrong answer3ms1812 KiB
2Accepted3ms2004 KiB
subtask20/20
3Accepted6ms2412 KiB
4Accepted1.044s4332 KiB
5Time limit exceeded1.557s4120 KiB
6Time limit exceeded1.565s4828 KiB
7Time limit exceeded1.549s5352 KiB
8Time limit exceeded1.565s5628 KiB
9Time limit exceeded1.541s5864 KiB
10Time limit exceeded1.557s6168 KiB
11Time limit exceeded1.57s6112 KiB
subtask30/35
12Accepted3ms3916 KiB
13Wrong answer3ms3948 KiB
14Wrong answer3ms4180 KiB
15Wrong answer3ms4256 KiB
16Wrong answer3ms4272 KiB
17Wrong answer3ms4156 KiB
18Wrong answer3ms4292 KiB
19Wrong answer3ms4372 KiB
20Wrong answer3ms4372 KiB
subtask40/45
21Accepted4ms4612 KiB
22Wrong answer958ms6312 KiB
23Time limit exceeded1.565s6360 KiB
24Time limit exceeded1.565s6920 KiB
25Time limit exceeded1.577s7160 KiB
26Time limit exceeded1.572s7116 KiB
27Time limit exceeded1.572s7160 KiB
28Time limit exceeded1.565s7172 KiB
29Time limit exceeded1.565s7164 KiB