#include<bits/stdc++.h>
using namespace std;
void solve(){
int n, m, k;cin >> n >> m >> k;
vector<int> g[n];
while(m--){
int u, v;cin >> u >> v;u--;v--;
g[u].push_back(v);
g[v].push_back(u);
}
queue<int> q;
int d[n] = {0};
string s;cin >> s;
int x[k];for(int i = 0;i < k;i++) {
cin >> x[i];
x[i]--;
}
d[x[0]]=0;
q.push(x[0]);
while(!q.empty()){
int t = q.front();
q.pop();
for(int j : g[t]){
if(!d[j] && j != x[0]){
q.push(j);
d[j]=d[t]+1;
}
}
}
for(int i = 0;i < n;i++) cout << d[i] << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
9 ms |
2908 KB |
Output is correct |
3 |
Correct |
14 ms |
4688 KB |
Output is correct |
4 |
Correct |
13 ms |
4380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
4188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
4188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
9 ms |
2908 KB |
Output is correct |
3 |
Correct |
14 ms |
4688 KB |
Output is correct |
4 |
Correct |
13 ms |
4380 KB |
Output is correct |
5 |
Incorrect |
1 ms |
636 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |