Submission #1110217

#TimeUsernameProblemLanguageResultExecution timeMemory
1110217vjudge1Board Game (JOI24_boardgame)C++17
3 / 100
20 ms6736 KiB
#include<bits/stdc++.h> #define fi first #define se second #define ll long long #define pb push_back using namespace std; int n,m,k,dis[100005],root[1000005]; vector<int> adj[100005]; string x; bool vis[100005]; int main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); // freopen(".INP","r",stdin); // freopen(".OUT","w",stdout); cin>>n>>m>>k; for(int i=1;i<=n;i++) { dis[i]=1e9; } for(int i=1;i<=m;i++) { int u,v; cin>>u>>v; adj[u].pb(v); adj[v].pb(u); } cin>>x; for(int i=1;i<=k;i++) cin>>root[i]; priority_queue<pair<int,int>> q; q.push({0,root[1]}); dis[root[1]]=0; while(!q.empty()) { int a=q.top().se;q.pop(); if(vis[a]) continue; vis[a]=true; for(auto b:adj[a]) { if(dis[b]>dis[a]+1) { dis[b]=dis[a]+1; q.push({-dis[b],b}); } } } for(int i=1;i<=n;i++) { cout<<dis[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...