6086 | 2023-10-29 17:47:02 | Ignác | Zsonglőrködés | cpp11 | Time limit exceeded 0/100 | 1.6s | 5712 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);
break;
}
}
}
cout << a.size();
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 3ms | 2204 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Accepted | 7ms | 2508 KiB | ||||
4 | Time limit exceeded | 1.544s | 2616 KiB | ||||
5 | Time limit exceeded | 1.565s | 3376 KiB | ||||
6 | Time limit exceeded | 1.569s | 3540 KiB | ||||
7 | Time limit exceeded | 1.577s | 3812 KiB | ||||
8 | Time limit exceeded | 1.56s | 3968 KiB | ||||
9 | Time limit exceeded | 1.569s | 4240 KiB | ||||
10 | Time limit exceeded | 1.565s | 4464 KiB | ||||
11 | Time limit exceeded | 1.546s | 4632 KiB | ||||
subtask3 | 0/35 | ||||||
12 | Accepted | 3ms | 3928 KiB | ||||
13 | Accepted | 2ms | 4028 KiB | ||||
14 | Accepted | 3ms | 3996 KiB | ||||
15 | Wrong answer | 3ms | 4000 KiB | ||||
16 | Accepted | 4ms | 4244 KiB | ||||
17 | Accepted | 4ms | 4288 KiB | ||||
18 | Accepted | 3ms | 4324 KiB | ||||
19 | Accepted | 4ms | 4456 KiB | ||||
20 | Wrong answer | 3ms | 4560 KiB | ||||
subtask4 | 0/45 | ||||||
21 | Accepted | 7ms | 4596 KiB | ||||
22 | Accepted | 1.144s | 5364 KiB | ||||
23 | Time limit exceeded | 1.582s | 4880 KiB | ||||
24 | Time limit exceeded | 1.6s | 5200 KiB | ||||
25 | Time limit exceeded | 1.57s | 5440 KiB | ||||
26 | Time limit exceeded | 1.577s | 5408 KiB | ||||
27 | Time limit exceeded | 1.57s | 5620 KiB | ||||
28 | Time limit exceeded | 1.549s | 5576 KiB | ||||
29 | Time limit exceeded | 1.554s | 5712 KiB |