Submission #213238

#TimeUsernameProblemLanguageResultExecution timeMemory
213238Dremix10Birmingham (COCI20_birmingham)C++17
70 / 70
276 ms11384 KiB
#include <bits/stdc++.h> using namespace std; int main (){ int n,m,q,k; cin>>n>>m>>q>>k; int sources[q]; int i; for(i=0;i<q;i++) cin>>sources[i]; vector <vector <int> > a(n+1,vector<int>()); for(i=0;i<m;i++){ int x,y; cin>>x>>y; a[x].push_back(y); a[y].push_back(x); } /* int j; for(i=1;i<=n;i++){ cout<<i<<" -> "; for(j=0;j<a[i].size();j++) cout<<a[i][j]<<" "; cout<<endl; } */ vector <int> d(n+1,1000000000); queue <int> qu; for(i=0;i<q;i++){ d[sources[i]]=0; qu.push(sources[i]); } while(!qu.empty()){ int start=qu.front(); qu.pop(); for(i=0;i<a[start].size();i++){ if(d[a[start][i]]>d[start]+1){ d[a[start][i]]=d[start]+1; qu.push(a[start][i]); } } } int fix[200000]; memset(fix,0,sizeof(fix)); long long curr=1; long long next=1; long long counter=0; fix[0]=0; for(i=1;i<200000;i++){ fix[i]=curr; counter++; if(counter==next){ curr++; next++; counter=0; } } for(i=1;i<=n;i++){ int ans=d[i]/k; if(d[i]%k>0) ans++; cout<<fix[ans]<<" "; } //cout<<endl; //for(i=1;i<=n;i++) // cout<<d[i]<<" "; }

Compilation message (stderr)

birmingham.cpp: In function 'int main()':
birmingham.cpp:46:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<a[start].size();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...