답안 #391538

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
391538 2021-04-19T09:22:03 Z phathnv Birmingham (COCI20_birmingham) C++11
70 / 70
138 ms 10452 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int, int> ii;

const int N = 1e5 + 1;

int n, m, q, k;
vector <int> known, adj[N];

int d[N];

void readInput(){
    scanf("%d %d %d %d", &n, &m, &q, &k);
    for(int i = 1; i <= q; i++){
        int x;
        scanf("%d", &x);
        known.push_back(x);
    }
    for(int i = 1; i <= m; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
}

void solve(){
    queue <int> qu;
    for(int i = 1; i <= n; i++)
        d[i] = -1;
    for(int x : known){
        d[x] = 0;
        qu.push(x);
    }

    while (!qu.empty()){
        int u = qu.front();
        qu.pop();

        for(int v : adj[u])
            if (d[v] == -1){
                d[v] = d[u] + 1;
                qu.push(v);
            }
    }

    for(int i = 1; i <= n; i++){
        int res = 0;
        int cur = k;
        while (d[i] > 0){
            res++;
            d[i] -= cur;
            cur += k;
        }
        printf("%d ", res);
    }
}

int main(){
    readInput();
    solve();
    return 0;
}

Compilation message

birmingham.cpp: In function 'void readInput()':
birmingham.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |     scanf("%d %d %d %d", &n, &m, &q, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
birmingham.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
birmingham.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |         scanf("%d %d", &u, &v);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2660 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 9300 KB Output is correct
2 Correct 104 ms 9848 KB Output is correct
3 Correct 105 ms 10340 KB Output is correct
4 Correct 82 ms 8772 KB Output is correct
5 Correct 84 ms 9008 KB Output is correct
6 Correct 104 ms 10452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 9792 KB Output is correct
2 Correct 102 ms 9540 KB Output is correct
3 Correct 99 ms 9940 KB Output is correct
4 Correct 102 ms 9892 KB Output is correct
5 Correct 103 ms 9572 KB Output is correct
6 Correct 88 ms 9796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 9412 KB Output is correct
2 Correct 111 ms 9832 KB Output is correct
3 Correct 108 ms 10220 KB Output is correct
4 Correct 138 ms 9792 KB Output is correct
5 Correct 93 ms 9144 KB Output is correct
6 Correct 91 ms 9876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 8980 KB Output is correct
2 Correct 113 ms 9560 KB Output is correct
3 Correct 108 ms 10020 KB Output is correct
4 Correct 93 ms 9272 KB Output is correct
5 Correct 87 ms 8944 KB Output is correct
6 Correct 108 ms 9660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 8968 KB Output is correct
2 Correct 98 ms 9388 KB Output is correct
3 Correct 95 ms 9540 KB Output is correct
4 Correct 95 ms 9216 KB Output is correct
5 Correct 98 ms 9296 KB Output is correct
6 Correct 109 ms 9660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 9028 KB Output is correct
2 Correct 122 ms 9380 KB Output is correct
3 Correct 91 ms 9528 KB Output is correct
4 Correct 101 ms 9572 KB Output is correct
5 Correct 93 ms 9224 KB Output is correct
6 Correct 114 ms 9828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 9188 KB Output is correct
2 Correct 90 ms 8908 KB Output is correct
3 Correct 114 ms 10216 KB Output is correct
4 Correct 90 ms 9156 KB Output is correct
5 Correct 132 ms 9420 KB Output is correct
6 Correct 112 ms 10428 KB Output is correct