Submission #238541

#TimeUsernameProblemLanguageResultExecution timeMemory
238541SalitoBirmingham (COCI20_birmingham)C++14
70 / 70
270 ms9272 KiB
#include<bits/stdc++.h> using namespace std; int const maxn = 100005; int n,m,q,k; int a[maxn]; vector<int>v[maxn]; void read() { int i; cin>>n>>m>>q>>k; for(i=0;i<q;i++) cin>>a[i]; int x,y; for(i=0;i<m;i++) { cin>>x>>y; v[x].push_back(y); v[y].push_back(x); } } int ans[maxn]; void bfs_solve() { queue<int>l; int i,sz; for(i=0;i<q;i++) { l.push(a[i]); ans[a[i]] = 1; } while(!l.empty()) { int t = l.front(); l.pop(); sz = v[t].size(); for(i=0;i<sz;i++) { int nb = v[t][i]; if(!ans[nb]) { ans[nb] = ans[t]+1; l.push(nb); } } } } int get_ans(int x) { if(x == 1) return 0; int t; x--; int i = 1; while(x - i*k > 0) { x-=i*k; i++; } return i; } void print() { int i; for(i=1;i<=n;i++) cout<<get_ans(ans[i])<<" "; cout<<endl; } int main() { read(); bfs_solve(); print(); return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'int get_ans(int)':
birmingham.cpp:59:9: warning: unused variable 't' [-Wunused-variable]
     int t;
         ^
#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...