#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,m,q,k;
vector<int> a[100004];
int used[100004];
int br;
int day=1;
void read()
{
memset(used,-1,sizeof(used));
cin>>n>>m>>q>>k;
br=n-q;
for(int i=1;i<=q;i++)
{
int x;
cin>>x;
used[x]=0;
}
for(int i=1;i<=m;i++)
{
int x,y;
cin>>x>>y;
a[x].push_back(y);
a[y].push_back(x);
}
}
void dfs(int x, int p)
{
if(p==0) return;
else
{
p-=1;
int sz=a[x].size();
for(int i=0;i<sz;i++)
{
int nb=a[x][i];
if(used[nb]==-1)
{
br--;
used[nb]=day;
dfs(nb,p);
}
}
}
}
void solve()
{
queue<int>q1;
while(br>0)
{
for(int i=1;i<=n;i++)
{
if(used[i]>-1)
{
q1.push(i);
}
}
while(!q1.empty())
{
int x=q1.front();
q1.pop();
dfs(x,day*k);
}
day++;
}
for(int i=2;i<=n;i++)
{
cout<<used[1];
cout<<" "<<used[i];
}
cout<<endl;
}
int main()
{
read();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
3072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
3072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
3072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
3072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
3072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
3072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
3072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
277 ms |
7800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
238 ms |
8008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
256 ms |
7924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
195 ms |
7636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
205 ms |
7656 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
235 ms |
7548 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
213 ms |
7800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |