Submission #219321

#TimeUsernameProblemLanguageResultExecution timeMemory
219321VEGAnnBirmingham (COCI20_birmingham)C++14
70 / 70
130 ms10368 KiB
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define PB push_back using namespace std; const int N = 100100; const int oo = 2e9; queue<int> q; vector<int> g[N]; int n, m, qq, k, dst[N]; int answer(int vl){ int sum = 0, nw = k, kol = 0; while (vl > sum){ sum += nw; nw += k; kol++; } return kol; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); // freopen("in.txt","r",stdin); cin >> n >> m >> qq >> k; fill(dst, dst + n, oo); for (int i = 0; i < qq; i++){ int x; cin >> x; x--; dst[x] = 0; q.push(x); } for (int i = 0; i < m; i++){ int x, y; cin >> x >> y; x--; y--; g[x].PB(y); g[y].PB(x); } while (sz(q)){ int v = q.front(); q.pop(); for (int u : g[v]) if (dst[u] == oo){ dst[u] = dst[v] + 1; q.push(u); } } for (int i = 0; i < n; i++) cout << answer(dst[i]) << " "; return 0; }
#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...