Submission #171016

#TimeUsernameProblemLanguageResultExecution timeMemory
171016juggernaut관광지 (IZhO14_shymbulak)C++14
50 / 100
874 ms1016 KiB
//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)); }

Compilation message (stderr)

shymbulak.cpp:7:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
shymbulak.cpp: In function 'int main()':
shymbulak.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
shymbulak.cpp:10: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...