# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
569076 | Waratpp123 | 철인 이종 경기 (APIO18_duathlon) | C++14 | 1097 ms | 1048576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
vector<long long> g[100010];
long long ans=0,sz[100010],n;
void findsz(long long i,long long p){
for(auto x: g[i]){
if(x==p) continue;
findsz(x,i);
}
sz[i]++;
for(auto x: g[i]){
if(x==p) continue;
sz[i]+=sz[x];
}
}
void findans(long long i,long long p){
long long sum=n-sz[i];
ans-=((n-sz[i])*(n-sz[i]));
for(auto x : g[i]){
if(x==p) continue;
sum+=sz[x];
ans-=(sz[x]*sz[x]);
}
ans+=(sum*sum);
for(auto x : g[i]){
if(x==p) continue;
findans(x,i);
}
}
int main(){
long long m,u,v,i;
scanf("%lld %lld",&n,&m);
for(i=1;i<=m;i++){
scanf("%lld %lld",&u,&v);
g[u].push_back(v);
g[v].push_back(u);
}
findsz(1,-1);
findans(1,-1);
printf("%lld\n",ans);
return 0;
}
컴파일 시 표준 에러 (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... |