Submission #238700

#TimeUsernameProblemLanguageResultExecution timeMemory
238700Niya_RBirmingham (COCI20_birmingham)C++14
70 / 70
265 ms9252 KiB
#include <iostream> #include<bits/stdc++.h> using namespace std; vector<int>v[100004]; queue<int>q1; int used[100004]; int ans[100004]; void bfs() { while(!q1.empty()) { int x=q1.front(); q1.pop(); int sz=v[x].size(); for(int i=0;i<sz;i++) { int nb=v[x][i]; if(used[nb]==-1) { used[nb]=used[x]+1; q1.push(nb); } } } } int main() { int n, m, q, k; cin>>n>>m>>q>>k; memset(used,-1,sizeof(used)); for(int i=1; i<=q; i++) { int x; cin>>x; used[x]=0; ans[x]=0; q1.push(x); } for(int i=1; i<=m; i++) { int x,y; cin>>x>>y; v[x].push_back(y); v[y].push_back(x); } bfs(); int br=q; for(int i=1;i<=200000;i++) { int l=0; for(int j=1;j<=n;j++) { if(used[j]>0) { l=1; used[j]-=i*k; if(used[j]<=0) ans[j]=i; } } if(l==0) break; } for(int i=1;i<=n;i++) cout<<ans[i]<<" "; cout<<endl; return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'int main()':
birmingham.cpp:47:9: warning: unused variable 'br' [-Wunused-variable]
     int br=q;
         ^~
#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...