# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
580478 | yutabi | 관광지 (IZhO14_shymbulak) | C++14 | 1592 ms | 8232 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef pair <ll,ll> ii;
int ans;
int best=-1;
int n;
vector <vector <int> > graph;
queue <int> q;
vector <int> d;
vector <int> c;
vector <bool> v;
int main()
{
scanf("%d",&n);
graph=vector <vector <int> > (n);
for(int i=0;i<n;i++)
{
int a,b;
scanf(" %d %d",&a,&b);
a--,b--;
graph[a].pb(b);
graph[b].pb(a);
}
for(int i=0;i<n;i++)
{
d=vector <int> (n,-1);
c=vector <int> (n,0);
v=vector <bool> (n,0);
d[i]=0;
c[i]=1;
q.push(i);
while(q.size())
{
int a=q.front();
q.pop();
if(v[a]==1)
{
continue;
}
v[a]=1;
if(d[a]>best)
{
best=d[a];
ans=0;
}
if(d[a]==best)
{
ans+=c[a];
}
for(int j=0;j<graph[a].size();j++)
{
if(v[graph[a][j]]==0)
{
q.push(graph[a][j]);
if(d[graph[a][j]]>d[a]+1 || d[graph[a][j]]==-1)
{
d[graph[a][j]]=d[a]+1;
c[graph[a][j]]=0;;
}
if(d[graph[a][j]]==d[a]+1)
{
c[graph[a][j]]+=c[a];
}
}
}
}
}
ans/=2;
printf("%d",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... |