Submission #710039

#TimeUsernameProblemLanguageResultExecution timeMemory
710039ToroTNBirmingham (COCI20_birmingham)C++14
70 / 70
121 ms9960 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back int n,m,num,a,u_i,v_i,k,d[100005],u,hsh[100005],sum=0; vector<int> v[100005]; queue<int> q; int main() { memset(d,-1,sizeof d); scanf("%d%d%d%d",&n,&m,&num,&k); for(int i=1;i<=100000;i++) { for(int j=1;j<=k*i;j++) { ++sum; //printf("%d %d\n",i,j); //printf("%d\n",sum); hsh[sum]=i; if(sum==100000)break; } if(sum==100000)break; } for(int i=1;i<=num;i++) { scanf("%d",&a); d[a]=0; q.push(a); } for(int i=1;i<=m;i++) { scanf("%d%d",&u_i,&v_i); v[u_i].pb(v_i); v[v_i].pb(u_i); } while(!q.empty()) { u=q.front(); //printf("%d %d\n",u,d[u]); q.pop(); for(auto node:v[u]) { if(d[node]==-1) { d[node]=d[u]+1; q.push(node); } } } //printf("%d\n",d[4]); for(int i=1;i<=n;i++) { printf("%d ",hsh[d[i]]); } printf("\n"); }

Compilation message (stderr)

birmingham.cpp: In function 'int main()':
birmingham.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d%d%d%d",&n,&m,&num,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
birmingham.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d",&a);
      |         ~~~~~^~~~~~~~~
birmingham.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d%d",&u_i,&v_i);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...