Submission #845125

#TimeUsernameProblemLanguageResultExecution timeMemory
845125vjudge1Birmingham (COCI20_birmingham)C++17
15 / 70
78 ms8936 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0); #define s second #define f first typedef long long ll; const ll MOD = 998244353; const ll LOGN = 20; const ll MAXN = 1e5 + 5; vector<vector<int>> graph; int vis[MAXN], dist[MAXN]; int main() { fast int N, M, Q, K; cin >> N >> M >> Q >> K; for (int i = 1; i <= N; i++) dist[i] = 1e8; queue<int> q; for (int i = 0; i < Q; i++) { int x; cin >> x; q.push(x); dist[x] = 0; } graph = vector<vector<int>>(N+1, vector<int>()); while (M--) { int a, b; cin >> a >> b; graph[a].push_back(b); graph[b].push_back(a); } while (!q.empty()) { int node = q.front(); q.pop(); for (auto u : graph[node]) { if (!vis[u] && dist[u] > dist[node] + 1) { dist[u] = dist[node] + 1; q.push(u); } } } for (int i = 1; i <= N; i++) { int cnt = (dist[i] != 0); int k = dist[i] - K; while (k > 0) { cnt++; k -= K; } cout << cnt << " "; } cout << "\n"; }
#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...