5238 | 2023-04-23 16:36:44 | szil | Energiatakarékos ellenőrzés | cpp14 | Wrong answer 0/100 | 61ms | 43928 KiB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
vector<int> g[MAXN];
int ans = 0;
int dfs(int x, int p = -1){
int r = 1;
for(int i : g[x]){
if(i==p)continue;
r += dfs(i, x);
}
if (g[x].size() != 1 || x == 1) ans += min(8, r*2);
return r;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
for (int i = 0; i < n - 1; i++) {
int a, b; cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
dfs(1);
cout<<ans<<"\n";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 4ms | 6668 KiB | ||||
2 | Wrong answer | 46ms | 14448 KiB | ||||
subtask2 | 0/5 | ||||||
3 | Wrong answer | 32ms | 15968 KiB | ||||
4 | Wrong answer | 32ms | 16840 KiB | ||||
5 | Wrong answer | 34ms | 17928 KiB | ||||
6 | Wrong answer | 32ms | 18772 KiB | ||||
7 | Wrong answer | 34ms | 19828 KiB | ||||
subtask3 | 0/15 | ||||||
8 | Accepted | 4ms | 13240 KiB | ||||
9 | Accepted | 4ms | 13452 KiB | ||||
10 | Wrong answer | 4ms | 13692 KiB | ||||
11 | Wrong answer | 4ms | 13340 KiB | ||||
12 | Wrong answer | 4ms | 13344 KiB | ||||
13 | Wrong answer | 4ms | 13344 KiB | ||||
14 | Wrong answer | 4ms | 13348 KiB | ||||
subtask4 | 0/15 | ||||||
15 | Wrong answer | 4ms | 13628 KiB | ||||
16 | Wrong answer | 4ms | 13528 KiB | ||||
17 | Wrong answer | 4ms | 13652 KiB | ||||
18 | Wrong answer | 4ms | 13584 KiB | ||||
19 | Wrong answer | 4ms | 13772 KiB | ||||
20 | Wrong answer | 4ms | 13660 KiB | ||||
21 | Wrong answer | 4ms | 13664 KiB | ||||
subtask5 | 0/65 | ||||||
22 | Wrong answer | 50ms | 21388 KiB | ||||
23 | Wrong answer | 46ms | 22544 KiB | ||||
24 | Wrong answer | 46ms | 23696 KiB | ||||
25 | Wrong answer | 46ms | 24852 KiB | ||||
26 | Wrong answer | 46ms | 26000 KiB | ||||
27 | Wrong answer | 56ms | 36836 KiB | ||||
28 | Wrong answer | 61ms | 40516 KiB | ||||
29 | Wrong answer | 50ms | 34396 KiB | ||||
30 | Wrong answer | 48ms | 32936 KiB | ||||
31 | Wrong answer | 48ms | 32036 KiB | ||||
32 | Wrong answer | 46ms | 33324 KiB | ||||
33 | Wrong answer | 46ms | 34480 KiB | ||||
34 | Wrong answer | 37ms | 36252 KiB | ||||
35 | Wrong answer | 35ms | 37436 KiB | ||||
36 | Wrong answer | 37ms | 39008 KiB | ||||
37 | Wrong answer | 39ms | 40120 KiB | ||||
38 | Wrong answer | 39ms | 41580 KiB | ||||
39 | Wrong answer | 39ms | 42856 KiB | ||||
40 | Wrong answer | 41ms | 43928 KiB |