# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
408062 | 2021-05-19T05:49:44 Z | juggernaut | 철인 이종 경기 (APIO18_duathlon) | C++17 | 93 ms | 10548 KB |
#include<bits/stdc++.h> using namespace std; #define endl '\n' typedef long long ll; int n,m; vector<int>g[100005]; ll ans; bool circle; bool vis[100005]; int sz; void dfs(int v,int p){ vis[v]=true; sz++; for(int to:g[v])if(to!=p){ if(vis[to]){ circle=true; continue; } dfs(to,v); } } int main(){ scanf("%d%d",&n,&m); while(m--){ int x,y; scanf("%d%d",&x,&y); g[x].push_back(y); g[y].push_back(x); } for(int i=1;i<=n;i++)if(!vis[i]){ circle=false; sz=0; dfs(i,i); ll s=sz*1ll; if(circle)ans+=s*(s-1)*(s-2); else for(int i=1;i<=sz;i++)ans+=2ll*(i-1)*(n-i); } printf("%lld",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2636 KB | Output is correct |
2 | Correct | 3 ms | 2636 KB | Output is correct |
3 | Correct | 2 ms | 2636 KB | Output is correct |
4 | Correct | 3 ms | 2568 KB | Output is correct |
5 | Correct | 3 ms | 2636 KB | Output is correct |
6 | Incorrect | 3 ms | 2636 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2636 KB | Output is correct |
2 | Correct | 3 ms | 2636 KB | Output is correct |
3 | Correct | 2 ms | 2636 KB | Output is correct |
4 | Correct | 3 ms | 2568 KB | Output is correct |
5 | Correct | 3 ms | 2636 KB | Output is correct |
6 | Incorrect | 3 ms | 2636 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 93 ms | 10548 KB | Output is correct |
2 | Correct | 58 ms | 10532 KB | Output is correct |
3 | Incorrect | 77 ms | 8192 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 2684 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 66 ms | 5960 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 2636 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 61 ms | 5912 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2636 KB | Output is correct |
2 | Correct | 3 ms | 2636 KB | Output is correct |
3 | Correct | 2 ms | 2636 KB | Output is correct |
4 | Correct | 3 ms | 2568 KB | Output is correct |
5 | Correct | 3 ms | 2636 KB | Output is correct |
6 | Incorrect | 3 ms | 2636 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2636 KB | Output is correct |
2 | Correct | 3 ms | 2636 KB | Output is correct |
3 | Correct | 2 ms | 2636 KB | Output is correct |
4 | Correct | 3 ms | 2568 KB | Output is correct |
5 | Correct | 3 ms | 2636 KB | Output is correct |
6 | Incorrect | 3 ms | 2636 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |