12882022-03-30 12:28:57FulopMateEnergiatakarékos ellenőrzéscpp14Wrong answer 5/10071ms40664 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer2ms1828 KiB
2Wrong answer54ms13996 KiB
subtask25/5
3Accepted35ms15368 KiB
4Accepted37ms16068 KiB
5Accepted32ms16908 KiB
6Accepted35ms17540 KiB
7Accepted35ms18452 KiB
subtask30/15
8Accepted1ms6876 KiB
9Wrong answer1ms6896 KiB
10Wrong answer1ms6908 KiB
11Wrong answer1ms6912 KiB
12Wrong answer1ms6892 KiB
13Accepted1ms6900 KiB
14Wrong answer1ms6908 KiB
subtask40/15
15Wrong answer1ms6908 KiB
16Wrong answer1ms6912 KiB
17Wrong answer1ms6916 KiB
18Wrong answer1ms6920 KiB
19Wrong answer1ms6924 KiB
20Accepted1ms6932 KiB
21Wrong answer1ms6932 KiB
subtask50/65
22Wrong answer52ms18932 KiB
23Wrong answer52ms20092 KiB
24Wrong answer52ms21372 KiB
25Wrong answer52ms22408 KiB
26Wrong answer54ms23556 KiB
27Wrong answer54ms30564 KiB
28Wrong answer68ms33276 KiB
29Wrong answer64ms30012 KiB
30Wrong answer71ms29612 KiB
31Wrong answer71ms29336 KiB
32Wrong answer65ms30484 KiB
33Wrong answer59ms31648 KiB
34Wrong answer39ms33536 KiB
35Wrong answer39ms34704 KiB
36Wrong answer39ms35968 KiB
37Wrong answer43ms37328 KiB
38Wrong answer43ms38492 KiB
39Wrong answer46ms39584 KiB
40Wrong answer48ms40664 KiB