Submission #218284

# Submission time Handle Problem Language Result Execution time Memory
218284 2020-04-01T19:42:42 Z dolphingarlic Birmingham (COCI20_birmingham) C++14
70 / 70
141 ms 13048 KB
/*
COCI 20 Birmingham
- Basically just do a BFS and binary search for the day
*/

#include <bits/stdc++.h>
#define FOR(i, x, y) for (ll i = x; i < y; i++)
typedef long long ll;
using namespace std;
 
vector<ll> graph[100001];
ll visited[100001];
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, m, p, k;
    cin >> n >> m >> p >> k;
    queue<ll> q;
    FOR(i, 0, p) {
        ll x;
        cin >> x;
        visited[x] = 1;
        q.push(x);
    }
    FOR(i, 0, m) {
        ll x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
 
    while (q.size()) {
        ll curr = q.front();
        q.pop();
        for (ll i : graph[curr]) if (!visited[i]) {
            visited[i] = visited[curr] + 1;
            q.push(i);
        }
    }
 
    FOR(i, 1, n + 1) {
        visited[i]--;
        ll l = 0, r = n;
        while (l != r) {
            ll mid = (l + r) / 2;
            if (visited[i] > k * mid * (mid + 1) / 2) l = mid + 1;
            else r = mid;
        }
        cout << l << ' ';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 11768 KB Output is correct
2 Correct 110 ms 12512 KB Output is correct
3 Correct 112 ms 12920 KB Output is correct
4 Correct 92 ms 11000 KB Output is correct
5 Correct 96 ms 11384 KB Output is correct
6 Correct 117 ms 13048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 12592 KB Output is correct
2 Correct 113 ms 12264 KB Output is correct
3 Correct 109 ms 12536 KB Output is correct
4 Correct 129 ms 12764 KB Output is correct
5 Correct 106 ms 12264 KB Output is correct
6 Correct 94 ms 11772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 11976 KB Output is correct
2 Correct 141 ms 12768 KB Output is correct
3 Correct 113 ms 12832 KB Output is correct
4 Correct 111 ms 12636 KB Output is correct
5 Correct 97 ms 11640 KB Output is correct
6 Correct 107 ms 11944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 11256 KB Output is correct
2 Correct 106 ms 12140 KB Output is correct
3 Correct 113 ms 12536 KB Output is correct
4 Correct 102 ms 11768 KB Output is correct
5 Correct 96 ms 11392 KB Output is correct
6 Correct 95 ms 11768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 11384 KB Output is correct
2 Correct 102 ms 11896 KB Output is correct
3 Correct 99 ms 11768 KB Output is correct
4 Correct 99 ms 11640 KB Output is correct
5 Correct 101 ms 11768 KB Output is correct
6 Correct 90 ms 11640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 11640 KB Output is correct
2 Correct 106 ms 11896 KB Output is correct
3 Correct 97 ms 11616 KB Output is correct
4 Correct 103 ms 12140 KB Output is correct
5 Correct 97 ms 11512 KB Output is correct
6 Correct 97 ms 12000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 11640 KB Output is correct
2 Correct 93 ms 11096 KB Output is correct
3 Correct 114 ms 12792 KB Output is correct
4 Correct 104 ms 11616 KB Output is correct
5 Correct 102 ms 12016 KB Output is correct
6 Correct 107 ms 12792 KB Output is correct