| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 408028 | juggernaut | 철인 이종 경기 (APIO18_duathlon) | C++17 | 1122 ms | 1048580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
int n,m;
int sz[100005];
vector<int>g[100005];
void dfs(int v,int p){
sz[v]=1;
for(int to:g[v])if(to!=p){
dfs(to,v);
sz[v]+=sz[to];
}
}
int root;
ll ans=0;
void calc(int v,int p){
ll sum=0;
vector<int>vec;
for(int to:g[v])if(to!=p)vec.push_back(sz[to]);
if(root^v)vec.push_back(sz[root]-sz[v]);
for(int x:vec)sum+=x;
for(int x:vec){
sum-=x;
ans+=1ll*x*sum;
sum+=x;
}
for(int to:g[v])if(to!=p)calc(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(root=1;root<=n;root++)if(!sz[root])dfs(root,root),calc(root,root);
printf("%lld",ans);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
