#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = (1 << 18);
vector < int > v[MAXN];
int n, m, q, k, d[MAXN], s[MAXN], used[MAXN];
void read()
{
cin >> n >> m >> q >> k;
for (int i = 1; i <= q; i ++)
cin >> s[i];
int a, b;
for (int i = 0; i < m; i ++)
{
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
}
void bfs()
{
queue < int > qt;
for (int i = 1; i <= q; i ++)
qt.push(s[i]), used[s[i]] = 1;
while(!qt.empty())
{
int cur = qt.front(), sz = v[cur].size();
qt.pop();
for (int i = 0; i < sz; i ++)
{
int next = v[cur][i];
if (!used[next])
{
used[next] = used[cur] + 1;
qt.push(next);
}
}
}
}
void fill_array()
{
int id = 1, step = 1;
while(id <= n)
{
int r = id + step * k - 1;
if (n < r)
n = r;
for (int i = id; i <= r; i ++)
d[i] = step;
id = r + 1;
step ++;
}
}
void solve()
{
read();
bfs();
fill_array();
for (int i = 1; i <= n; i ++)
{
int x = used[i] - 1;
cout << d[x] << " ";
}
cout << endl;
}
int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
6528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
132 ms |
13684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
110 ms |
14136 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
115 ms |
13784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
91 ms |
13288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
99 ms |
13416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
99 ms |
13412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
99 ms |
13536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |