Submission #137857

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

const int N = 100001;

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;
        cout << cur << endl;
        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 8 ms 5368 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 4 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5240 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 4 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 5368 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 8 ms 5368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -