# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170847 | juggernaut | Shymbulak (IZhO14_shymbulak) | C++14 | 1554 ms | 10352 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int mx,cnt,n,x,y,i;
bool vis[200001];
vector<vector<int>>g(200001);
void dfs(int v,int cost){
vis[v]=1;
if(cost>mx){
mx=cost;
cnt=1;
}else if(cost==mx)cnt++;
for(int to:g[v])
if(!vis[to])dfs(to,cost+1);
vis[v]=0;
}
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=0;i<n;i++)dfs(i+1,0);
printf("%lld",cnt>>1);
}
Compilation message (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... |