Submission #845193

#TimeUsernameProblemLanguageResultExecution timeMemory
845193vjudge1Birmingham (COCI20_birmingham)C++17
35 / 70
121 ms11152 KiB
#include <bits/stdc++.h> #define endl "\n" #define pb push_back #define int long long using namespace std; const int inf = 2e18 + 5; const int N = 5e3 + 5; const int mod = 998244353; int32_t main(){ //freopen("in.txt","r", stdin); int n, m, q, k; cin>>n>>m>>q>>k; vector<int> st(q); vector<int> dis(n+1, mod); for(int i = 0; i < q; i++){ cin>>st[i]; dis[st[i]] = 0; } vector<int> adj[n+1]; for(int i = 0; i < m; i++){ int u, v; cin>>u>>v; adj[u].pb(v); adj[v].pb(u); } queue<int> qq; vector<int> vis(n+1); for(int i = 0; i < q; i++){ qq.push(st[i]); vis[st[i]] = 1; } while(!qq.empty()){ int x = qq.front(); qq.pop(); for(auto itr: adj[x]){ if(!vis[itr]){ vis[itr] = 1; dis[itr] = dis[x] + 1, dis[itr]; //cout<<itr<<" "<<dis[itr]<<endl; qq.push(itr); } } } for(int i = 1; i <= n; i++){ int x = dis[i], ans = 0, kk = k; while(x > 0){ x -= kk; kk *= 2; ans++; } cout<<ans<<" "; } 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...