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>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 100005
using namespace std;
bool vis[N];
int way[N];
vector <vector<int> > adj(N);
int32_t main(){
fast
int n, m, q, k;
cin>>n>>m>>q>>k;
queue <pair<int, int> > que;
for(int i = 0; i < q; i++) {
int in;
cin>>in;
que.push({in, 0});
vis[in] = 1;
}
for(int i = 0; i < m; i++) {
int a, b;
cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
}
while(!que.empty()) {
int node = que.front().first, dis = que.front().second;
way[node] = dis;
que.pop();
for(auto it:adj[node]) {
if(vis[it]) continue;
vis[it] = 1;
que.push({it, dis + 1});
}
}
for(int i = 1; i <= n; i++) {
int val = 0, tk = k;
while(way[i] > 0) {
way[i] -= tk;
tk += k;
val++;
}
cout<<val<<" ";
}
}
# | 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... |