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 = 1e5+5;
int n, m, q, k;
vector<int> G[N];
int dist[N];
void bfs()
{
queue<int> Q;
for(int i = 1; i <= n; i ++)
if(dist[i] == 0) Q.push(i);
while(Q.size())
{
int u = Q.front();
Q.pop();
for(int v : G[u])
if(dist[u] + 1 < dist[v])
{
dist[v] = dist[u] + 1;
Q.push(v);
}
}
}
int main()
{
cin >> n >> m >> q >> k;
for(int i = 1; i <= n; i ++)
dist[i] = N * 4;
for(int i = 0; i < q; i ++)
{
int x;
cin >> x;
dist[x] = 0;
}
for(int i = 0; i < m; i ++)
{
int u, v;
cin >> u >> v;
G[u].push_back(v);
G[v].push_back(u);
}
bfs();
for(int i = 1; i <= n; i ++)
{
int x = 0, add = 0, sm = 0;
while(dist[i] > add)
{
x ++;
sm += k;
add += sm;
}
cout << x << ' ';
}
cout << endl;
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... |