Submission #170847

#TimeUsernameProblemLanguageResultExecution timeMemory
170847juggernautShymbulak (IZhO14_shymbulak)C++14
0 / 100
1554 ms10352 KiB
//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)

shymbulak.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
shymbulak.cpp: In function 'int main()':
shymbulak.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
shymbulak.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...