Submission #999057

#TimeUsernameProblemLanguageResultExecution timeMemory
999057vjudge1Birmingham (COCI20_birmingham)C++17
20 / 70
115 ms7740 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int const N=1e5+5; int const inf=1e9+7; int dist[N]; deque<int> v; vector<int> adj[N]; int main(){ int n,m,q,k; cin>>n>>m>>q>>k; for(int i=0;i<=n;i++) dist[i]=inf; for(int i=1;i<=q;i++){ int a; cin>>a; v.push_back(a); dist[a]=0; } for(int i=0;i<m;i++){ int u,v; cin>>u>>v; adj[u].push_back(v); adj[v].push_back(u); } while(v.size()){ int node=v[0]; // cout<<node<<' '<<dist[node]<<endl; v.pop_front(); for(int u:adj[node]) if(dist[u]>dist[node]+1){ dist[u]=dist[node]+1; v.push_back(u); } } for(int i=1;i<=n;i++){ int low=-1,high=100001; while(high-low>1){ ll mid=(high+low)/2; if(mid*(mid+1)>=dist[i]*2) high=mid; else low=mid; } cout<<high<<' '; } cout<<endl; 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...
#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...