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;
const int N = 2e5 + 10;
int n, m, p, k, dist[N];
queue<int> q;
vector<int> g[N];
int main(){
memset(dist, 31, sizeof dist);
cin >> n >> m >> p >> k;
for (int i = 0; i < p; i ++){
int v;
cin >> v;
q.push(v);
dist[v] = 0;
}
for (int i = 0; i < m; i ++){
int u, v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
while (!q.empty()){
int v = q.front();
q.pop();
for (int u : g[v]){
if (dist[u] > dist[v] + 1){
q.push(u);
dist[u] = dist[v] + 1;
}
}
}
for (int i = 1; i <= n; i ++){
int sm = 0;
for (int x = 0; x <= n; x ++){
sm += (x * k);
if (dist[i] <= sm){
cout << x << " ";
break;
}
}
}
cout << endl;
}
# | 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... |