Submission #1110280

#TimeUsernameProblemLanguageResultExecution timeMemory
1110280vjudge1Board Game (JOI24_boardgame)C++98
3 / 100
23 ms4688 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...