Submission #1019546

#TimeUsernameProblemLanguageResultExecution timeMemory
1019546ndanBirmingham (COCI20_birmingham)C++14
70 / 70
70 ms10840 KiB
// Practice makes perfect #include <bits/stdc++.h> #include <queue> using namespace std; #define fastIO ios_base::sync_with_stdio(0); cin.tie(0); #define file "bmh" #define ll long long const int maxn = 1e5 + 5; int n, m, q, ans[maxn], d[maxn]; ll k; bool vis[maxn]; queue<int> qu; vector<int> g[maxn]; void bfs() { while (qu.size()) { int u = qu.front(); qu.pop(); for (int i = 0; i < g[u].size(); ++i) { int v = g[u][i]; if (!vis[v]) { vis[v] = 1; qu.push(v); d[v] = d[u] + 1; } } } } int main() { fastIO cin >> n >> m >> q >> k; for (int i = 1; i <= n; ++i) ans[i] = INT_MAX; for (int i = 1; i <= q; ++i) { int x; cin >> x; qu.push(x); vis[x] = 1; d[x] = 0; ans[x] = 0; } while (m--) { int x, y; cin >> x >> y; g[x].push_back(y); g[y].push_back(x); } bfs(); for (int i = 1; i <= n; ++i) { if (!d[i]) continue; int lo = 1, hi = n; while (lo <= hi) { ll mi = (lo + hi) >> 1; if ((mi * (mi + 1) / 2) * k >= d[i]) { ans[i] = min(ans[i], (int) mi); hi = mi - 1; } else lo = mi + 1; } } for (int i = 1; i <= n; ++i) cout << ans[i] << " "; return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'void bfs()':
birmingham.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int i = 0; i < g[u].size(); ++i) {
      |                         ~~^~~~~~~~~~~~~
#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...