Submission #238702

#TimeUsernameProblemLanguageResultExecution timeMemory
238702TrayanaGBirmingham (COCI20_birmingham)C++14
70 / 70
273 ms11128 KiB
#include<iostream> #include<bits/stdc++.h> using namespace std; int n,m,q,k; int a[200020]; int used[200020]; vector <int> v[200020]; int br = 0; queue<int>g; void read() { memset(used, -1, sizeof(used)); cin>>n>>m>>q>>k; for(int i=1; i<=q; i++) { cin>>a[i]; used[a[i]] = 0; g.push(a[i]); } int x,y; for(int i=1; i<=m; i++) { cin>>x>>y; v[x].push_back(y); v[y].push_back(x); } } void BFS() { while(!g.empty()) { int w = g.front(); g.pop(); int nb; int sz = v[w].size(); for(int j=0; j<sz; j++) { nb = v[w][j]; if(used[nb]==-1) { used[nb] = used[w]+1; g.push(nb); } } } } int answer[200500]; int main() { read(); BFS(); int k1 = k; for(int j=1; j<=200000; j++) { int lamp=0; for(int i=1; i<=n; i++) { if(used[i]>0) { lamp = 1; used[i]-=j*k; if(used[i]<=0)answer[i] = j; } } if(lamp==0)break; } cout<<answer[1]; for(int i=2; i<=n; i++) { cout<<" "<<answer[i]; } cout<<endl; return 0; }

Compilation message (stderr)

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