#include<bits/stdc++.h>
using namespace std;
int const maxn = 100005;
int n,m,q,k;
int a[maxn];
vector<int>v[maxn];
void read()
{
int i;
cin>>n>>m>>q>>k;
for(i=0;i<q;i++)
cin>>a[i];
int x,y;
for(i=0;i<m;i++)
{
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
}
int ans[maxn];
queue<int>gq;
void dfs(int i, int d, int p)
{
if(d == 0)return ;
int j,sz=v[i].size();
for(j=0;j<sz;j++)
{
int nb = v[i][j];
if(!ans[nb])
{
gq.push(nb);
ans[nb] = ans[p]+1;
dfs(nb,d-1,p);
}
}
}
void bfs_solve()
{
int i;
for(i=0;i<q;i++)
{
gq.push(a[i]);
ans[a[i]] = 1;
}
while(!gq.empty())
{
int t = gq.front();
gq.pop();
dfs(t,k*ans[t],t);
}
}
void print()
{
int i;
for(i=1;i<=n;i++)
cout<<ans[i]-1<<" ";
cout<<endl;
}
int main()
{
read();
bfs_solve();
print();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
229 ms |
8312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
266 ms |
8664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
225 ms |
8440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
214 ms |
8184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
211 ms |
8188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
248 ms |
8388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
228 ms |
8312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |