# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1019546 | 2024-07-11T03:27:00 Z | ndan | Birmingham (COCI20_birmingham) | C++14 | 70 ms | 10840 KB |
// 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2908 KB | Output is correct |
2 | Correct | 2 ms | 2652 KB | Output is correct |
3 | Correct | 2 ms | 2652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2908 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 2 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2652 KB | Output is correct |
2 | Correct | 2 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 2 ms | 2816 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 2 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 10020 KB | Output is correct |
2 | Correct | 65 ms | 10312 KB | Output is correct |
3 | Correct | 56 ms | 10832 KB | Output is correct |
4 | Correct | 51 ms | 9524 KB | Output is correct |
5 | Correct | 51 ms | 9528 KB | Output is correct |
6 | Correct | 49 ms | 10840 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 62 ms | 10324 KB | Output is correct |
2 | Correct | 49 ms | 10256 KB | Output is correct |
3 | Correct | 54 ms | 10320 KB | Output is correct |
4 | Correct | 62 ms | 10384 KB | Output is correct |
5 | Correct | 70 ms | 10244 KB | Output is correct |
6 | Correct | 52 ms | 10064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 9920 KB | Output is correct |
2 | Correct | 56 ms | 10392 KB | Output is correct |
3 | Correct | 59 ms | 10576 KB | Output is correct |
4 | Correct | 52 ms | 10552 KB | Output is correct |
5 | Correct | 46 ms | 9812 KB | Output is correct |
6 | Correct | 51 ms | 10032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 9564 KB | Output is correct |
2 | Correct | 50 ms | 10224 KB | Output is correct |
3 | Correct | 51 ms | 10364 KB | Output is correct |
4 | Correct | 48 ms | 10024 KB | Output is correct |
5 | Correct | 42 ms | 9552 KB | Output is correct |
6 | Correct | 44 ms | 10072 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 9556 KB | Output is correct |
2 | Correct | 51 ms | 9996 KB | Output is correct |
3 | Correct | 58 ms | 9932 KB | Output is correct |
4 | Correct | 48 ms | 9664 KB | Output is correct |
5 | Correct | 45 ms | 9820 KB | Output is correct |
6 | Correct | 44 ms | 9820 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 9588 KB | Output is correct |
2 | Correct | 50 ms | 10084 KB | Output is correct |
3 | Correct | 46 ms | 9816 KB | Output is correct |
4 | Correct | 51 ms | 10136 KB | Output is correct |
5 | Correct | 52 ms | 9808 KB | Output is correct |
6 | Correct | 59 ms | 10064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 9808 KB | Output is correct |
2 | Correct | 45 ms | 9388 KB | Output is correct |
3 | Correct | 58 ms | 10588 KB | Output is correct |
4 | Correct | 46 ms | 9808 KB | Output is correct |
5 | Correct | 50 ms | 10128 KB | Output is correct |
6 | Correct | 52 ms | 10688 KB | Output is correct |