1288 | 2022-03-30 12:28:57 | FulopMate | Energiatakarékos ellenőrzés | cpp14 | Wrong answer 5/100 | 71ms | 40664 KiB |
#include <bits/stdc++.h>
using namespace std;
//#define __TEST_CASE_TEXT
#define __TEST_CASE_BEFORE "Case #"
#define __TEST_CASE_AFTER ": "
#define ll long long
#define all(c) (c).begin(), (c).end()
#define MIN(a, b) ((a) = min((a), (b)))
#define MAX(a, b) ((a) = max((a), (b)))
const ll MOD = 1e9+7;
const int abc = 'z'-'a'+1;
ll ans = 0;
vector<vector<int>> v;
int dfs(int x, int p = -1){
ll c = 0;
for(int i : v[x]){
if(i != p){
c += dfs(i, x) + 2;
}
}
ans += c;
return c;
}
void solve(){
int n; cin>>n;
v.assign(n, {});
for(int i = 0; i < n-1; i++){
int a, b; cin>>a>>b; a--; b--;
v[a].push_back(b);
v[b].push_back(a);
}
dfs(0);
cout<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int _t;
_t = 1;
for(int _i = 0; _i < _t; _i++){
#ifdef __TEST_CASE_TEXT
cout<<__TEST_CASE_BEFORE<<_i+1<<__TEST_CASE_AFTER;
#endif
solve();
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 2ms | 1828 KiB | ||||
2 | Wrong answer | 54ms | 13996 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 35ms | 15368 KiB | ||||
4 | Accepted | 37ms | 16068 KiB | ||||
5 | Accepted | 32ms | 16908 KiB | ||||
6 | Accepted | 35ms | 17540 KiB | ||||
7 | Accepted | 35ms | 18452 KiB | ||||
subtask3 | 0/15 | ||||||
8 | Accepted | 1ms | 6876 KiB | ||||
9 | Wrong answer | 1ms | 6896 KiB | ||||
10 | Wrong answer | 1ms | 6908 KiB | ||||
11 | Wrong answer | 1ms | 6912 KiB | ||||
12 | Wrong answer | 1ms | 6892 KiB | ||||
13 | Accepted | 1ms | 6900 KiB | ||||
14 | Wrong answer | 1ms | 6908 KiB | ||||
subtask4 | 0/15 | ||||||
15 | Wrong answer | 1ms | 6908 KiB | ||||
16 | Wrong answer | 1ms | 6912 KiB | ||||
17 | Wrong answer | 1ms | 6916 KiB | ||||
18 | Wrong answer | 1ms | 6920 KiB | ||||
19 | Wrong answer | 1ms | 6924 KiB | ||||
20 | Accepted | 1ms | 6932 KiB | ||||
21 | Wrong answer | 1ms | 6932 KiB | ||||
subtask5 | 0/65 | ||||||
22 | Wrong answer | 52ms | 18932 KiB | ||||
23 | Wrong answer | 52ms | 20092 KiB | ||||
24 | Wrong answer | 52ms | 21372 KiB | ||||
25 | Wrong answer | 52ms | 22408 KiB | ||||
26 | Wrong answer | 54ms | 23556 KiB | ||||
27 | Wrong answer | 54ms | 30564 KiB | ||||
28 | Wrong answer | 68ms | 33276 KiB | ||||
29 | Wrong answer | 64ms | 30012 KiB | ||||
30 | Wrong answer | 71ms | 29612 KiB | ||||
31 | Wrong answer | 71ms | 29336 KiB | ||||
32 | Wrong answer | 65ms | 30484 KiB | ||||
33 | Wrong answer | 59ms | 31648 KiB | ||||
34 | Wrong answer | 39ms | 33536 KiB | ||||
35 | Wrong answer | 39ms | 34704 KiB | ||||
36 | Wrong answer | 39ms | 35968 KiB | ||||
37 | Wrong answer | 43ms | 37328 KiB | ||||
38 | Wrong answer | 43ms | 38492 KiB | ||||
39 | Wrong answer | 46ms | 39584 KiB | ||||
40 | Wrong answer | 48ms | 40664 KiB |