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 ll long long
#define ar array
const int mxN=1e5;
int n, m, starts, k;
int d[mxN];
vector<int> adj[mxN];
queue<int> q;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> starts >> k;
fill(d, d+n, -1);
for (int i=0; i<starts; ++i) {
int a; cin >> a, --a;
d[a]=0;
q.push(a);
}
for (int i=0; i<m; ++i) {
int a, b; cin >> a >> b, --a, --b;
adj[a].push_back(b);
adj[b].push_back(a);
}
while(!q.empty()) {
int u=q.front(); q.pop();
for (int v : adj[u]) if (d[v]==-1) {
d[v]=d[u]+1;
q.push(v);
}
}
for (int i=0; i<n; ++i) {
int ans=0;
for (int j=1; d[i]>0; ++j) {
++ans;
d[i]-=k*j;
}
cout << ans << " ";
}
return 0;
}
# | 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... |