# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
262364 | 2020-08-12T17:17:32 Z | CaroLinda | Duathlon (APIO18_duathlon) | C++14 | 79 ms | 11384 KB |
#include <bits/stdc++.h> #define lp(i,a,b) for(int i = a; i < b ; i++) #define ff first #define ss second #define pb emplace_back #define ll long long #define mk make_pair #define sz(x) x.size() #define pii pair<int,int> #define mkt make_tuple #define debug const int MAXN = 1e5+10 ; using namespace std ; int N , M ; ll sub[MAXN] ; ll resp ; bool vis[MAXN] ; vector<int> adj[MAXN] ; void dfs(int x) { vis[x] = true ; sub[x] = 0LL ; for(auto y : adj[x] ) { if(vis[y]) continue ; dfs(y) ; resp += sub[x] * sub[y] * 2LL ; resp += sub[y] * (sub[y]-1) ; sub[x] += sub[y] ; } sub[x]++ ; } int main() { scanf("%d%d", &N , &M ) ; for(int i = 1 , u , v ; i <= M ; i++ ) { scanf("%d%d", &u, &v ) ; adj[u].pb(v) ; adj[v].pb(u) ; } lp(i,1,N+1) if(!vis[i]) dfs(i) ; printf("%lld\n" , resp ) ; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 79 ms | 11384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 63 ms | 6776 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 63 ms | 6776 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |