#include <bits/stdc++.h>
#define lg(a) (31 - __builtin_clz((a)))
#define endl ("\n")
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define vi vector<int>
#define st first
#define nd second
#define all(aa) aa.begin(), aa.end()
#define rall(aa) aa.rbegin(), aa.rend()
#define until(n, v) (int) (lower_bound(v.begin(), v.end(), n)-v.begin()) //# of elements < n
#define after(n, v) (int) (v.end()-upper_bound(v.begin(), v.end(), n)) //# of elements > n
#define sameas(n, v) (int) (upper_bound(v.begin(), v.end(), n) - lower_bound(v.begin(), v.end(), n)) //# of elements ==n
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;
/*
*/
void solve(){
int n, m, k, qq;
cin >> n >> m >> qq >> k;
queue<int> q;
vector<int> ans(n, -1);
for(int i=0; i<qq; i++){
int a; cin >> a;
a--;
q.push(a);
ans[a] = 0;
}
vector<vector<int>> g(n);
for(int i=0; i < m; i++){
int a, b; cin >> a >> b;
a--, b--;
g[a].pb(b);
g[b].pb(a);
}
while(!q.empty()){
int v = q.front();
q.pop();
for(auto u : g[v]){
if(ans[u]==-1){
ans[u] = ans[v] + 1;
q.push(u);
}
}
}
for(int i=0;i<n;i++){
int l = 0, r= n;
while(l<r){
int mid = (l+r)/2;
if(1ll*mid*(mid+1)*k/2 < ans[i])
l = mid+1;
else if(1ll*mid*(mid+1)*k/2 >= ans[i])
r = mid;
}
cout<<r<<' ';
}
}
int main(){
int test;
// cin >> test;
test =1;
while (test--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
432 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
436 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
436 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
432 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
436 KB |
Output is correct |
4 |
Correct |
0 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
9552 KB |
Output is correct |
2 |
Correct |
115 ms |
9812 KB |
Output is correct |
3 |
Correct |
127 ms |
10064 KB |
Output is correct |
4 |
Correct |
98 ms |
8960 KB |
Output is correct |
5 |
Correct |
95 ms |
9032 KB |
Output is correct |
6 |
Correct |
121 ms |
10068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
9836 KB |
Output is correct |
2 |
Correct |
114 ms |
9648 KB |
Output is correct |
3 |
Correct |
125 ms |
9812 KB |
Output is correct |
4 |
Correct |
138 ms |
10068 KB |
Output is correct |
5 |
Correct |
111 ms |
9812 KB |
Output is correct |
6 |
Correct |
144 ms |
9556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
9548 KB |
Output is correct |
2 |
Correct |
116 ms |
9816 KB |
Output is correct |
3 |
Correct |
119 ms |
10064 KB |
Output is correct |
4 |
Correct |
122 ms |
10044 KB |
Output is correct |
5 |
Correct |
105 ms |
9300 KB |
Output is correct |
6 |
Correct |
112 ms |
9564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
9052 KB |
Output is correct |
2 |
Correct |
112 ms |
9608 KB |
Output is correct |
3 |
Correct |
118 ms |
10064 KB |
Output is correct |
4 |
Correct |
106 ms |
9328 KB |
Output is correct |
5 |
Correct |
98 ms |
8940 KB |
Output is correct |
6 |
Correct |
106 ms |
9552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
9044 KB |
Output is correct |
2 |
Correct |
103 ms |
9300 KB |
Output is correct |
3 |
Correct |
124 ms |
9528 KB |
Output is correct |
4 |
Correct |
100 ms |
9296 KB |
Output is correct |
5 |
Correct |
105 ms |
9304 KB |
Output is correct |
6 |
Correct |
105 ms |
9396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
9044 KB |
Output is correct |
2 |
Correct |
105 ms |
9492 KB |
Output is correct |
3 |
Correct |
109 ms |
9260 KB |
Output is correct |
4 |
Correct |
109 ms |
9608 KB |
Output is correct |
5 |
Correct |
102 ms |
9264 KB |
Output is correct |
6 |
Correct |
111 ms |
9696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
98 ms |
9300 KB |
Output is correct |
2 |
Correct |
100 ms |
8840 KB |
Output is correct |
3 |
Correct |
127 ms |
10152 KB |
Output is correct |
4 |
Correct |
99 ms |
9148 KB |
Output is correct |
5 |
Correct |
106 ms |
9496 KB |
Output is correct |
6 |
Correct |
121 ms |
10064 KB |
Output is correct |