# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
866131 | 2023-10-25T13:03:37 Z | alexander707070 | 철인 이종 경기 (APIO18_duathlon) | C++14 | 1000 ms | 1048576 KB |
#include<bits/stdc++.h> #define MAXN 100007 using namespace std; long long n,m,a,b; long long sz[MAXN]; vector<int> v[MAXN]; long long ans; void dfs(int x,int p){ sz[x]=1; for(int i=0;i<v[x].size();i++){ if(v[x][i]==p)continue; dfs(v[x][i],x); sz[x]+=sz[v[x][i]]; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i=1;i<=m;i++){ cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } dfs(1,0); for(long long i=1;i<=n;i++){ ans+=(n-1)*(n-2); for(int f=0;f<v[i].size();f++){ if(sz[v[i][f]]<sz[i]){ ans-=sz[v[i][f]]*(sz[v[i][f]]-1); }else{ ans-=(n-sz[i])*(n-sz[i]-1); } } } cout<<ans<<"\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 592 ms | 1048576 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 592 ms | 1048576 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1062 ms | 995728 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2904 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2904 KB | Output is correct |
8 | Correct | 1 ms | 2660 KB | Output is correct |
9 | Correct | 1 ms | 2656 KB | Output is correct |
10 | Incorrect | 1 ms | 2652 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 8016 KB | Output is correct |
2 | Correct | 27 ms | 8028 KB | Output is correct |
3 | Correct | 27 ms | 8024 KB | Output is correct |
4 | Correct | 26 ms | 7944 KB | Output is correct |
5 | Correct | 28 ms | 7912 KB | Output is correct |
6 | Correct | 29 ms | 11356 KB | Output is correct |
7 | Correct | 31 ms | 10096 KB | Output is correct |
8 | Correct | 29 ms | 9408 KB | Output is correct |
9 | Correct | 27 ms | 9044 KB | Output is correct |
10 | Incorrect | 26 ms | 8020 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2856 KB | Output is correct |
3 | Runtime error | 668 ms | 1048576 KB | Execution killed with signal 9 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 7932 KB | Output is correct |
2 | Correct | 25 ms | 8028 KB | Output is correct |
3 | Runtime error | 741 ms | 1048576 KB | Execution killed with signal 9 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 592 ms | 1048576 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 592 ms | 1048576 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |