Submission #137858

# Submission time Handle Problem Language Result Execution time Memory
137858 2019-07-28T12:46:34 Z Osama_Alkhodairy Circle selection (APIO18_circle_selection) C++17
0 / 100
12 ms 9980 KB
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 200001;

int n, m;
vector <int> v[N];
ll ans;

int dfs(int node, int pnode){
    int ret = 1;
    for(auto &i : v[node]){
        if(i == pnode) continue;
        int cur = dfs(i, node);
        ret += cur;
        ans += 1LL * cur * (n - cur);
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++){
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1, 0);
    ans *= 2;
    ans -= 2LL * n * (n - 1) / 2;
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 9980 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 9980 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 9980 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 9980 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -