This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |