#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()
int main(){
double k;
int n, m, qq;
cin>>n>>m>>qq>>k;
queue<pair<int, int>> q;
for(int i=0; i<qq; i++){
int a;
cin>>a;
q.push({a-1, 0});
}
vector<vector<int>> g(n);
for(int i=0; i<m; i++){
int a, b;
cin>>a>>b;
a--; b--;
g[a].push_back(b);
g[b].push_back(a);
}
vector<int> ans(n, -1);
while(q.size()){
auto[v, d]=q.front();
q.pop();
if(ans[v]!=-1) continue;
ans[v]=ceil((sqrt(k*k/4+2*k*d)-k/2)/k);
for(auto ch:g[v])
if(ans[v]!=-1) q.push({ch, d+1});
}
for(auto e:ans) cout<<e<<' ';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
436 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 |
348 KB |
Output is correct |
3 |
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 |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
8296 KB |
Output is correct |
2 |
Correct |
114 ms |
8560 KB |
Output is correct |
3 |
Correct |
147 ms |
9368 KB |
Output is correct |
4 |
Correct |
124 ms |
7796 KB |
Output is correct |
5 |
Correct |
92 ms |
8000 KB |
Output is correct |
6 |
Correct |
118 ms |
9612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
9008 KB |
Output is correct |
2 |
Correct |
104 ms |
8492 KB |
Output is correct |
3 |
Correct |
110 ms |
8928 KB |
Output is correct |
4 |
Correct |
137 ms |
8632 KB |
Output is correct |
5 |
Correct |
149 ms |
8688 KB |
Output is correct |
6 |
Correct |
101 ms |
8912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
8348 KB |
Output is correct |
2 |
Correct |
111 ms |
8744 KB |
Output is correct |
3 |
Correct |
144 ms |
9488 KB |
Output is correct |
4 |
Correct |
140 ms |
8780 KB |
Output is correct |
5 |
Correct |
103 ms |
8180 KB |
Output is correct |
6 |
Correct |
107 ms |
8784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
8160 KB |
Output is correct |
2 |
Correct |
104 ms |
8592 KB |
Output is correct |
3 |
Correct |
113 ms |
9040 KB |
Output is correct |
4 |
Correct |
103 ms |
8268 KB |
Output is correct |
5 |
Correct |
138 ms |
7996 KB |
Output is correct |
6 |
Correct |
109 ms |
8584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
8020 KB |
Output is correct |
2 |
Correct |
122 ms |
8472 KB |
Output is correct |
3 |
Correct |
115 ms |
8684 KB |
Output is correct |
4 |
Correct |
103 ms |
8252 KB |
Output is correct |
5 |
Correct |
134 ms |
8272 KB |
Output is correct |
6 |
Correct |
108 ms |
8536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
8096 KB |
Output is correct |
2 |
Correct |
140 ms |
8348 KB |
Output is correct |
3 |
Correct |
109 ms |
8596 KB |
Output is correct |
4 |
Correct |
155 ms |
8524 KB |
Output is correct |
5 |
Correct |
112 ms |
8156 KB |
Output is correct |
6 |
Correct |
109 ms |
8996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
133 ms |
8212 KB |
Output is correct |
2 |
Correct |
114 ms |
8024 KB |
Output is correct |
3 |
Correct |
119 ms |
9284 KB |
Output is correct |
4 |
Correct |
117 ms |
8268 KB |
Output is correct |
5 |
Correct |
116 ms |
8440 KB |
Output is correct |
6 |
Correct |
145 ms |
9524 KB |
Output is correct |