12202022-03-26 14:31:25Valaki2Energiatakarékos ellenőrzéscpp14Wrong answer 5/10082ms42248 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const int maxn = 1e5;

int n;
vector<int> g[maxn + 1];
int ans, on;

void dfs(int cur, int par) {
    ans += on;
    on++;
    for(int nei : g[cur]) {
        if(nei != par) {
            dfs(nei, cur);
        }
    }
    on--;
    ans += on;
}

void solve() {
    cin >> n;
    for(int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(1, 0);
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer4ms6592 KiB
2Wrong answer75ms15276 KiB
subtask25/5
3Accepted41ms16352 KiB
4Accepted45ms17064 KiB
5Accepted39ms17880 KiB
6Accepted39ms18392 KiB
7Accepted35ms19424 KiB
subtask30/15
8Accepted3ms11592 KiB
9Wrong answer3ms11596 KiB
10Wrong answer3ms11656 KiB
11Wrong answer3ms11680 KiB
12Wrong answer3ms11604 KiB
13Accepted3ms11612 KiB
14Wrong answer3ms11676 KiB
subtask40/15
15Wrong answer4ms11688 KiB
16Wrong answer4ms11704 KiB
17Wrong answer4ms11624 KiB
18Wrong answer3ms11632 KiB
19Wrong answer4ms11632 KiB
20Accepted3ms11644 KiB
21Wrong answer3ms11640 KiB
subtask50/65
22Wrong answer65ms20252 KiB
23Wrong answer57ms21416 KiB
24Wrong answer61ms22564 KiB
25Wrong answer61ms23720 KiB
26Wrong answer64ms24984 KiB
27Wrong answer81ms30808 KiB
28Wrong answer82ms33488 KiB
29Wrong answer76ms31136 KiB
30Wrong answer75ms30740 KiB
31Wrong answer79ms30632 KiB
32Wrong answer79ms31728 KiB
33Wrong answer63ms32820 KiB
34Wrong answer43ms34500 KiB
35Wrong answer43ms35664 KiB
36Wrong answer43ms36848 KiB
37Wrong answer48ms38300 KiB
38Wrong answer50ms39512 KiB
39Wrong answer50ms40876 KiB
40Wrong answer54ms42248 KiB