This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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();
vis[node] = true;
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 = 0;
int now = K;
int d = dist[i];
while (d > 0) {
d -= now;
cnt++;
now += K;
}
cout << cnt << " ";
}
cout << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |