#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
#define N +400500
//#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
ll d[N], n, m, q, k, x, y, i, pr[N];
priority_queue <ll, vector <ll> > qu;
vector <ll> g[N];
int main()
{
srand(time(0));
ios_base::sync_with_stdio(0);
iostream::sync_with_stdio(0);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
// in("input.txt");
// out("output.txt");
cin >> n >> m >> q >> k;
for (i = 1; i <= n; i++) d[i] = 1e9;
for (i = 1; i <= n; i++) pr[i] = i + pr[i - 1];
for (i = 1; i <= n; i++) pr[i] = pr[i] * k;
for (i = 1; i <= q; i++)
{
cin >> x;
d[x] = 0;
qu.push(x);
}
for (i = 1; i <= m; i++)
{
cin >> x >> y;
g[x].pb(y);
g[y].pb(x);
}
while (qu.size())
{
int v = qu.top();qu.pop();
for (auto u : g[v])
if (d[u] > d[v] + 1)
{
d[u] = d[v] + 1;
qu.push(u);
}
}
for (i = 1; i <= n; i++)
{
if (d[i] == 0) cout << "0 ";
else cout << (lower_bound(pr + 1, pr + 1 + n, d[i]) - pr) << " ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
10 ms |
9728 KB |
Output is correct |
3 |
Correct |
11 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
9728 KB |
Output is correct |
2 |
Correct |
10 ms |
9856 KB |
Output is correct |
3 |
Correct |
10 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
9728 KB |
Output is correct |
2 |
Correct |
12 ms |
9728 KB |
Output is correct |
3 |
Correct |
10 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
10 ms |
9856 KB |
Output is correct |
3 |
Correct |
10 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
10 ms |
9728 KB |
Output is correct |
3 |
Correct |
11 ms |
9728 KB |
Output is correct |
4 |
Correct |
10 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
10 ms |
9728 KB |
Output is correct |
3 |
Correct |
10 ms |
9728 KB |
Output is correct |
4 |
Correct |
10 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
10 ms |
9728 KB |
Output is correct |
3 |
Correct |
10 ms |
9728 KB |
Output is correct |
4 |
Correct |
10 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
401 ms |
19796 KB |
Output is correct |
2 |
Correct |
347 ms |
20204 KB |
Output is correct |
3 |
Correct |
163 ms |
18548 KB |
Output is correct |
4 |
Correct |
321 ms |
19184 KB |
Output is correct |
5 |
Correct |
377 ms |
19436 KB |
Output is correct |
6 |
Correct |
137 ms |
18540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
424 ms |
20204 KB |
Output is correct |
2 |
Correct |
335 ms |
20208 KB |
Output is correct |
3 |
Correct |
141 ms |
18292 KB |
Output is correct |
4 |
Correct |
404 ms |
22376 KB |
Output is correct |
5 |
Correct |
439 ms |
22116 KB |
Output is correct |
6 |
Correct |
113 ms |
17772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
353 ms |
19824 KB |
Output is correct |
2 |
Correct |
365 ms |
20328 KB |
Output is correct |
3 |
Correct |
137 ms |
18548 KB |
Output is correct |
4 |
Correct |
368 ms |
20332 KB |
Output is correct |
5 |
Correct |
351 ms |
19700 KB |
Output is correct |
6 |
Correct |
120 ms |
17904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
361 ms |
19484 KB |
Output is correct |
2 |
Correct |
318 ms |
19952 KB |
Output is correct |
3 |
Correct |
154 ms |
18420 KB |
Output is correct |
4 |
Correct |
376 ms |
19900 KB |
Output is correct |
5 |
Correct |
395 ms |
19308 KB |
Output is correct |
6 |
Correct |
126 ms |
18032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
353 ms |
19436 KB |
Output is correct |
2 |
Correct |
351 ms |
19688 KB |
Output is correct |
3 |
Correct |
165 ms |
17912 KB |
Output is correct |
4 |
Correct |
425 ms |
19628 KB |
Output is correct |
5 |
Correct |
412 ms |
19696 KB |
Output is correct |
6 |
Correct |
120 ms |
17644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
415 ms |
19412 KB |
Output is correct |
2 |
Correct |
405 ms |
19816 KB |
Output is correct |
3 |
Correct |
124 ms |
17780 KB |
Output is correct |
4 |
Correct |
399 ms |
19960 KB |
Output is correct |
5 |
Correct |
342 ms |
19720 KB |
Output is correct |
6 |
Correct |
119 ms |
17900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
353 ms |
19632 KB |
Output is correct |
2 |
Correct |
412 ms |
19280 KB |
Output is correct |
3 |
Correct |
153 ms |
18520 KB |
Output is correct |
4 |
Correct |
397 ms |
19716 KB |
Output is correct |
5 |
Correct |
348 ms |
19824 KB |
Output is correct |
6 |
Correct |
149 ms |
18608 KB |
Output is correct |