5240 | 2023-04-23 16:53:59 | szil | Energiatakarékos ellenőrzés | cpp14 | Accepted 100/100 | 61ms | 23204 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;
int c = dfs(i, x);
r += c;
ans += min(8, 2*c);
}
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 | 6664 KiB | ||||
2 | Accepted | 43ms | 13300 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 34ms | 13856 KiB | ||||
4 | Accepted | 32ms | 14068 KiB | ||||
5 | Accepted | 32ms | 14164 KiB | ||||
6 | Accepted | 32ms | 14172 KiB | ||||
7 | Accepted | 34ms | 14340 KiB | ||||
subtask3 | 15/15 | ||||||
8 | Accepted | 4ms | 7764 KiB | ||||
9 | Accepted | 4ms | 7972 KiB | ||||
10 | Accepted | 4ms | 8280 KiB | ||||
11 | Accepted | 4ms | 8352 KiB | ||||
12 | Accepted | 4ms | 8308 KiB | ||||
13 | Accepted | 4ms | 8560 KiB | ||||
14 | Accepted | 4ms | 8896 KiB | ||||
subtask4 | 15/15 | ||||||
15 | Accepted | 4ms | 8736 KiB | ||||
16 | Accepted | 4ms | 8656 KiB | ||||
17 | Accepted | 4ms | 8720 KiB | ||||
18 | Accepted | 4ms | 8660 KiB | ||||
19 | Accepted | 4ms | 8660 KiB | ||||
20 | Accepted | 4ms | 8660 KiB | ||||
21 | Accepted | 4ms | 8920 KiB | ||||
subtask5 | 65/65 | ||||||
22 | Accepted | 50ms | 15560 KiB | ||||
23 | Accepted | 46ms | 15568 KiB | ||||
24 | Accepted | 45ms | 15728 KiB | ||||
25 | Accepted | 46ms | 15732 KiB | ||||
26 | Accepted | 45ms | 15708 KiB | ||||
27 | Accepted | 48ms | 21584 KiB | ||||
28 | Accepted | 50ms | 23204 KiB | ||||
29 | Accepted | 50ms | 18676 KiB | ||||
30 | Accepted | 46ms | 17016 KiB | ||||
31 | Accepted | 48ms | 15772 KiB | ||||
32 | Accepted | 61ms | 15704 KiB | ||||
33 | Accepted | 57ms | 15724 KiB | ||||
34 | Accepted | 35ms | 16256 KiB | ||||
35 | Accepted | 35ms | 16316 KiB | ||||
36 | Accepted | 43ms | 16568 KiB | ||||
37 | Accepted | 37ms | 16664 KiB | ||||
38 | Accepted | 39ms | 16864 KiB | ||||
39 | Accepted | 45ms | 16996 KiB | ||||
40 | Accepted | 39ms | 16820 KiB |