#include <bits/stdc++.h>
using namespace std;
int n,m,k;
vector<int> v[50005];
int p[50005];
string s;
bool mark[50005];
int d[50005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m >> k;
for(int i=0;i<m;i++)
{
int x,y;
cin >>x >> y;
x--;y--;
v[x].push_back(y);
v[y].push_back(x);
}
cin >> s;
for(int i=0;i<k;i++)
{
cin >> p[i];
p[i]--;
}
queue<int> q;
q.push(p[0]);
mark[p[0]]=true;
while(!q.empty())
{
int x=q.front();
q.pop();
for(auto z:v[x])
{
if(mark[z]==false)
{
d[z]=d[x]+1;
mark[z]=true;
q.push(z);
}
}
}
for(int i=0;i<n;i++)
{
cout << d[i] << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1616 KB |
Output is correct |
2 |
Correct |
15 ms |
2860 KB |
Output is correct |
3 |
Correct |
23 ms |
4688 KB |
Output is correct |
4 |
Correct |
17 ms |
4176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
3664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
3664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1616 KB |
Output is correct |
2 |
Correct |
15 ms |
2860 KB |
Output is correct |
3 |
Correct |
23 ms |
4688 KB |
Output is correct |
4 |
Correct |
17 ms |
4176 KB |
Output is correct |
5 |
Incorrect |
3 ms |
1616 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |