#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 5, MOD = 1e9 + 7;
int dist[N];
bool visited[N];
vector<int> adj[N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, asd, k;
cin >> n >> m >> asd >> k;
queue<int> q;
for(int i = 0; i < asd; i++)
{
int x;
cin >> x;
dist[x] = 0;
visited[x] = true;
q.push(x);
}
for(int i = 0; i < m; i++)
{
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
while(q.size())
{
auto node = q.front();
q.pop();
for(auto to : adj[node])
{
if(!visited[to])
{
dist[to] = dist[node] + 1;
visited[to] = true;
q.push(to);
}
}
}
for(int i = 1; i <= n; i++)
{
ll l = 0, r = 100000, ans;
// cout << dist[i] << '\n';
while(l <= r)
{
ll mid = (l + r) / 2;
if(dist[i] <= k * (mid * (mid + 1)) / 2)
{
r = mid - 1;
ans = mid;
}
else
{
l = mid + 1;
}
}
cout << ans << " ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4952 KB |
Output is correct |
3 |
Correct |
1 ms |
4952 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
10004 KB |
Output is correct |
2 |
Correct |
59 ms |
10064 KB |
Output is correct |
3 |
Correct |
54 ms |
10320 KB |
Output is correct |
4 |
Correct |
47 ms |
9812 KB |
Output is correct |
5 |
Correct |
45 ms |
9812 KB |
Output is correct |
6 |
Correct |
52 ms |
10132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
10228 KB |
Output is correct |
2 |
Correct |
48 ms |
9972 KB |
Output is correct |
3 |
Correct |
51 ms |
10064 KB |
Output is correct |
4 |
Correct |
72 ms |
10324 KB |
Output is correct |
5 |
Correct |
52 ms |
10080 KB |
Output is correct |
6 |
Correct |
45 ms |
9796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
9816 KB |
Output is correct |
2 |
Correct |
51 ms |
10320 KB |
Output is correct |
3 |
Correct |
60 ms |
10324 KB |
Output is correct |
4 |
Correct |
51 ms |
10320 KB |
Output is correct |
5 |
Correct |
45 ms |
9816 KB |
Output is correct |
6 |
Correct |
51 ms |
10356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
9808 KB |
Output is correct |
2 |
Correct |
50 ms |
10064 KB |
Output is correct |
3 |
Correct |
52 ms |
10088 KB |
Output is correct |
4 |
Correct |
46 ms |
9804 KB |
Output is correct |
5 |
Correct |
64 ms |
9556 KB |
Output is correct |
6 |
Correct |
45 ms |
9708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
9652 KB |
Output is correct |
2 |
Correct |
53 ms |
9920 KB |
Output is correct |
3 |
Correct |
53 ms |
9808 KB |
Output is correct |
4 |
Correct |
56 ms |
9812 KB |
Output is correct |
5 |
Correct |
50 ms |
9812 KB |
Output is correct |
6 |
Correct |
50 ms |
9784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
9812 KB |
Output is correct |
2 |
Correct |
50 ms |
9868 KB |
Output is correct |
3 |
Correct |
56 ms |
9860 KB |
Output is correct |
4 |
Correct |
57 ms |
10068 KB |
Output is correct |
5 |
Correct |
46 ms |
9700 KB |
Output is correct |
6 |
Correct |
58 ms |
10108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
9912 KB |
Output is correct |
2 |
Correct |
81 ms |
9968 KB |
Output is correct |
3 |
Correct |
56 ms |
10068 KB |
Output is correct |
4 |
Correct |
45 ms |
9808 KB |
Output is correct |
5 |
Correct |
54 ms |
10052 KB |
Output is correct |
6 |
Correct |
56 ms |
10176 KB |
Output is correct |