제출 #1258459

#제출 시각아이디문제언어결과실행 시간메모리
1258459E_rKBirmingham (COCI20_birmingham)C++20
70 / 70
105 ms16196 KiB
#include <bits/stdc++.h> #define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false) #define pb push_back #define ppb pop_back #define fi first #define se second #define sp " " #define endl "\n" #define mod 1000000000 #define MAXN 200005 #define MAXM 1000006 #define inf 1e18 #define INF 0x3f #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define debug(x) for(auto& a: x) cout << a << " " using namespace std; typedef long long int lo; lo n,m,p,q,k,l,a,b; lo arr[MAXN],vis[MAXN],when[MAXN]; vector<lo> v[MAXN]; string s; bool check(lo mid, lo i){ return when[mid] >= arr[i]; } void solve(){ cin >> n >> m >> p >> k; when[1] = k; for (int i = 2; i <= n; ++i) { when[i] = when[i-1] + i*k; // cout << when[i] << endl; } queue<pair<lo,lo>> q; for (int i = 0; i < p; ++i) { cin >> a; q.push({0,a}); } for (int i = 0; i < m; ++i) { cin >> a >> b; v[a].pb(b); v[b].pb(a); } while(!q.empty()){ lo node = q.front().se; lo cost = q.front().fi; q.pop(); if(vis[node]) continue; arr[node] = cost; vis[node] = 1; for(auto go: v[node]){ if(!vis[go]) q.push({cost+1,go}); } } for (int i = 1; i <= n; ++i) { lo bas = 0; lo son = n; while(bas <= son){ lo mid = (bas+son)/2; if(check(mid,i)){ son = mid-1; } else{ bas = mid+1; } } cout << bas << sp; } } int main() { // cout << fixed << setprecision(12); // freopen("feast.in","r",stdin); // freopen("feast.out","w",stdout); fast; int t = 1; // cin >> t; while(t--) { solve(); } }
#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...