Submission #845166

#TimeUsernameProblemLanguageResultExecution timeMemory
845166vjudge1Birmingham (COCI20_birmingham)C++17
70 / 70
81 ms10356 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 2e5 + 5, MOD = 1e9 + 7; int dist[N]; bool visited[N]; vector<int> adj[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, asd, k; cin >> n >> m >> asd >> k; queue<int> q; for(int i = 0; i < asd; i++) { int x; cin >> x; dist[x] = 0; visited[x] = true; q.push(x); } for(int i = 0; i < m; i++) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } while(q.size()) { auto node = q.front(); q.pop(); for(auto to : adj[node]) { if(!visited[to]) { dist[to] = dist[node] + 1; visited[to] = true; q.push(to); } } } for(int i = 1; i <= n; i++) { ll l = 0, r = 100000, ans; // cout << dist[i] << '\n'; while(l <= r) { ll mid = (l + r) / 2; if(dist[i] <= k * (mid * (mid + 1)) / 2) { r = mid - 1; ans = mid; } else { l = mid + 1; } } cout << ans << " "; } }
#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...