#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(0);
mark[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 |
Incorrect |
3 ms |
1616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
15 ms |
3664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 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 |
Incorrect |
3 ms |
1616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |