답안 #1019178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1019178 2024-07-10T14:38:06 Z Tri_Pahm Birmingham (COCI20_birmingham) C++14
70 / 70
60 ms 10836 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
    //freopen(file".inp", "r", stdin);
    //freopen(file".out", "w", stdout);
    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

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) {
      |                         ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2908 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 9808 KB Output is correct
2 Correct 53 ms 10324 KB Output is correct
3 Correct 52 ms 10704 KB Output is correct
4 Correct 39 ms 9300 KB Output is correct
5 Correct 42 ms 9556 KB Output is correct
6 Correct 48 ms 10836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 10376 KB Output is correct
2 Correct 45 ms 10140 KB Output is correct
3 Correct 48 ms 10336 KB Output is correct
4 Correct 51 ms 10576 KB Output is correct
5 Correct 48 ms 10312 KB Output is correct
6 Correct 47 ms 10324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 10076 KB Output is correct
2 Correct 53 ms 10576 KB Output is correct
3 Correct 57 ms 10580 KB Output is correct
4 Correct 49 ms 10584 KB Output is correct
5 Correct 44 ms 9808 KB Output is correct
6 Correct 42 ms 10068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 9508 KB Output is correct
2 Correct 47 ms 10064 KB Output is correct
3 Correct 49 ms 10456 KB Output is correct
4 Correct 44 ms 9812 KB Output is correct
5 Correct 42 ms 9552 KB Output is correct
6 Correct 42 ms 10084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 9556 KB Output is correct
2 Correct 51 ms 9928 KB Output is correct
3 Correct 45 ms 10068 KB Output is correct
4 Correct 45 ms 9728 KB Output is correct
5 Correct 50 ms 10064 KB Output is correct
6 Correct 46 ms 10036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 9628 KB Output is correct
2 Correct 46 ms 10048 KB Output is correct
3 Correct 42 ms 9812 KB Output is correct
4 Correct 47 ms 10068 KB Output is correct
5 Correct 44 ms 9672 KB Output is correct
6 Correct 42 ms 10216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 9772 KB Output is correct
2 Correct 41 ms 9492 KB Output is correct
3 Correct 51 ms 10576 KB Output is correct
4 Correct 42 ms 9812 KB Output is correct
5 Correct 46 ms 10068 KB Output is correct
6 Correct 47 ms 10576 KB Output is correct