| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 171016 | juggernaut | 관광지 (IZhO14_shymbulak) | C++14 | 874 ms | 1016 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
vector<vector<int>>g(5001);
int a[5001],n,x,y,i,j,mx,cnt,b[5001];
main(){
scanf("%lld",&n);
for(i=0;i<n;i++){
scanf("%lld%lld",&x,&y);
g[x].push_back(y);
g[y].push_back(x);
}
for(i=1;i<=n;i++){
queue<int>q;
q.push(i);
for(j=1;j<=n;j++)a[j]=1e15,b[j]=0;
b[i]=1;
a[i]=0;
while(!q.empty()){
x=q.front();
q.pop();
for(int to:g[x])
if(a[to]>a[x]+1){
b[to]+=b[x];
a[to]=a[x]+1;
q.push(to);
}else if(a[to]==a[x]+1)b[to]+=b[x];
}
for(j=1;j<=n;j++)
if(a[j]>mx){
mx=a[j];
cnt=b[j];
}else if(mx==a[j])cnt+=b[j];
}
printf("%lld",(cnt>>1));
}
컴파일 시 표준 에러 (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... | ||||
