Submission #845073

#TimeUsernameProblemLanguageResultExecution timeMemory
845073vjudge1Birmingham (COCI20_birmingham)C++17
70 / 70
81 ms12884 KiB
#include "bits/stdc++.h" using namespace std; #define pb push_back #define endl "\n" #define int long long #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() void solve(){ int n,m,q,k; cin >> n >> m >> q >> k; int dist[n+1]; for(int i=1;i<=n;i++) dist[i]=100000000; queue<int> que; for(int i=1;i<=q;i++) { int a; cin >> a; dist[a]=0; que.push(a); } vector<int> v[n+1]; for(int i=1;i<=m;i++) { int a,b; cin >> a >> b; v[a].pb(b); v[b].pb(a); } while(!que.empty()) { int c=que.front(); que.pop(); for(int x:v[c]) { if(dist[c] + 1 < dist[x]) { dist[x] = dist[c] + 1; que.push(x); } } } for(int i=1;i<=n;i++) { if(dist[i]==0) { cout << 0 << " "; continue; } int ans=1; int right=k; while(dist[i]>right) { ans++; right+=ans*k; } cout << ans << " "; } cout << endl; } int32_t main(){ cin.tie(0); ios::sync_with_stdio(0); int t=1;//cin >> t; while(t--) solve(); 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...