#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define N 100005
int n, m, q, k, d[N];
vector<int> g[N];
vector<int> st;
int main()
{
memset(d, 63, sizeof d);
cin.tie(0); ios::sync_with_stdio(0);
cin >> n >> m >> q >> k;
for (ll i = k, x = 0; x < 1e7; x += i, i += k)
{
st.push_back(x);
}
priority_queue<pair<int, int>> Q;
for (int i = 0, x; i < q; i++)
{
cin >> x;
Q.emplace(0, x);
d[x] = 0;
}
for (int i = 0, u, v; i < m; i++)
{
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
while (Q.size())
{
auto [c, u] = Q.top(); Q.pop(); c = -c;
if (d[u] != c) continue;
for (auto v : g[u])
{
if (c + 1 < d[v])
{
d[v] = d[u]+1;
Q.emplace(-d[v], v);
}
}
}
for (int i = 1; i <= n; i++)
{
auto it = lower_bound(st.begin(), st.end(), d[i]) - st.begin();
cout << it << ' ';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
2 ms |
3064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
2 ms |
3156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3064 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
2 ms |
3028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
2 ms |
3056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2952 KB |
Output is correct |
2 |
Correct |
2 ms |
3148 KB |
Output is correct |
3 |
Correct |
2 ms |
3064 KB |
Output is correct |
4 |
Correct |
2 ms |
3028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3028 KB |
Output is correct |
2 |
Correct |
3 ms |
3064 KB |
Output is correct |
3 |
Correct |
2 ms |
3028 KB |
Output is correct |
4 |
Correct |
2 ms |
3028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3028 KB |
Output is correct |
2 |
Correct |
2 ms |
3028 KB |
Output is correct |
3 |
Correct |
3 ms |
3060 KB |
Output is correct |
4 |
Correct |
2 ms |
3028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
95 ms |
9728 KB |
Output is correct |
2 |
Correct |
93 ms |
10152 KB |
Output is correct |
3 |
Correct |
91 ms |
10388 KB |
Output is correct |
4 |
Correct |
77 ms |
9060 KB |
Output is correct |
5 |
Correct |
78 ms |
9384 KB |
Output is correct |
6 |
Correct |
89 ms |
10384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
10060 KB |
Output is correct |
2 |
Correct |
105 ms |
9884 KB |
Output is correct |
3 |
Correct |
101 ms |
10032 KB |
Output is correct |
4 |
Correct |
84 ms |
10184 KB |
Output is correct |
5 |
Correct |
93 ms |
10004 KB |
Output is correct |
6 |
Correct |
88 ms |
9824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
106 ms |
9740 KB |
Output is correct |
2 |
Correct |
93 ms |
10156 KB |
Output is correct |
3 |
Correct |
98 ms |
10340 KB |
Output is correct |
4 |
Correct |
112 ms |
10152 KB |
Output is correct |
5 |
Correct |
99 ms |
9528 KB |
Output is correct |
6 |
Correct |
81 ms |
9840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
9260 KB |
Output is correct |
2 |
Correct |
89 ms |
9912 KB |
Output is correct |
3 |
Correct |
98 ms |
10316 KB |
Output is correct |
4 |
Correct |
94 ms |
9736 KB |
Output is correct |
5 |
Correct |
73 ms |
9324 KB |
Output is correct |
6 |
Correct |
78 ms |
9768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
9344 KB |
Output is correct |
2 |
Correct |
97 ms |
9708 KB |
Output is correct |
3 |
Correct |
88 ms |
9600 KB |
Output is correct |
4 |
Correct |
81 ms |
9520 KB |
Output is correct |
5 |
Correct |
100 ms |
9716 KB |
Output is correct |
6 |
Correct |
84 ms |
9640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
9320 KB |
Output is correct |
2 |
Correct |
91 ms |
9728 KB |
Output is correct |
3 |
Correct |
82 ms |
9480 KB |
Output is correct |
4 |
Correct |
87 ms |
9976 KB |
Output is correct |
5 |
Correct |
91 ms |
9540 KB |
Output is correct |
6 |
Correct |
79 ms |
9888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
85 ms |
9472 KB |
Output is correct |
2 |
Correct |
106 ms |
9204 KB |
Output is correct |
3 |
Correct |
95 ms |
10216 KB |
Output is correct |
4 |
Correct |
80 ms |
9452 KB |
Output is correct |
5 |
Correct |
83 ms |
9832 KB |
Output is correct |
6 |
Correct |
88 ms |
10364 KB |
Output is correct |