5239 | 2023-04-23 16:48:53 | szil | Energiatakarékos ellenőrzés | cpp14 | Wrong answer 0/100 | 78ms | 27964 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 = g[x].size() - (x != 1);
for(int i : g[x]){
if(i==p)continue;
r += dfs(i, x);
}
ans += min(8, r*2);
return r;
}
int dfs2(int x, int p = -1){
int r = (x == 1 ? 2 : (g[x].size()-1)*2);
for(int i : g[x]){
if(i==p)continue;
r += dfs2(i, x);
}
ans += min(8*(int)(g[x].size()), r);
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);
}
dfs2(1);
cout<<ans<<"\n";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 4ms | 6668 KiB | ||||
2 | Wrong answer | 46ms | 13408 KiB | ||||
subtask2 | 0/5 | ||||||
3 | Wrong answer | 32ms | 13980 KiB | ||||
4 | Wrong answer | 32ms | 13936 KiB | ||||
5 | Wrong answer | 32ms | 14072 KiB | ||||
6 | Wrong answer | 32ms | 14172 KiB | ||||
7 | Wrong answer | 32ms | 14384 KiB | ||||
subtask3 | 0/15 | ||||||
8 | Wrong answer | 4ms | 7952 KiB | ||||
9 | Wrong answer | 4ms | 8140 KiB | ||||
10 | Wrong answer | 4ms | 8316 KiB | ||||
11 | Wrong answer | 4ms | 8512 KiB | ||||
12 | Accepted | 4ms | 8528 KiB | ||||
13 | Wrong answer | 4ms | 8488 KiB | ||||
14 | Accepted | 4ms | 8760 KiB | ||||
subtask4 | 0/15 | ||||||
15 | Wrong answer | 4ms | 8824 KiB | ||||
16 | Wrong answer | 4ms | 8880 KiB | ||||
17 | Wrong answer | 4ms | 9004 KiB | ||||
18 | Wrong answer | 4ms | 8912 KiB | ||||
19 | Wrong answer | 4ms | 8908 KiB | ||||
20 | Wrong answer | 4ms | 8964 KiB | ||||
21 | Accepted | 4ms | 9216 KiB | ||||
subtask5 | 0/65 | ||||||
22 | Wrong answer | 46ms | 15612 KiB | ||||
23 | Wrong answer | 45ms | 15560 KiB | ||||
24 | Wrong answer | 46ms | 15568 KiB | ||||
25 | Wrong answer | 45ms | 15568 KiB | ||||
26 | Wrong answer | 45ms | 15836 KiB | ||||
27 | Wrong answer | 52ms | 25476 KiB | ||||
28 | Wrong answer | 78ms | 27964 KiB | ||||
29 | Wrong answer | 61ms | 20796 KiB | ||||
30 | Wrong answer | 57ms | 18172 KiB | ||||
31 | Wrong answer | 59ms | 16064 KiB | ||||
32 | Wrong answer | 46ms | 16088 KiB | ||||
33 | Wrong answer | 52ms | 16040 KiB | ||||
34 | Accepted | 35ms | 16716 KiB | ||||
35 | Accepted | 43ms | 16924 KiB | ||||
36 | Wrong answer | 35ms | 17092 KiB | ||||
37 | Wrong answer | 37ms | 17060 KiB | ||||
38 | Wrong answer | 39ms | 17220 KiB | ||||
39 | Wrong answer | 37ms | 17268 KiB | ||||
40 | Wrong answer | 46ms | 17096 KiB |