Submission #674203

# Submission time Handle Problem Language Result Execution time Memory
674203 2022-12-23T13:19:03 Z Jarif_Rahman Duathlon (APIO18_duathlon) C++17
0 / 100
1000 ms 1048576 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int n, m;
vector<vector<int>> graph;
vector<bool> bl;

ll cnt = 0;
void dfs(int nd, int ss){
    cnt++;
    bl[nd] = 1;
    for(int x: graph[nd]) if(x != ss) dfs(x, nd);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;
    graph.resize(n);
    bl.resize(n, 0);

    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b; a--, b--;
        graph[a].pb(b);
        graph[b].pb(a);
    }

    ll ans = 0;
    for(int i = 0; i < n; i++) if(!bl[i]){
        cnt = 0;
        dfs(i, -1);
        ans+=(cnt*(cnt-1)*(cnt-2))/3;
    }

    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Runtime error 577 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 577 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1111 ms 490244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 5880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 5840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 577 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 577 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -