답안 #693987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
693987 2023-02-03T13:55:14 Z Gital Birmingham (COCI20_birmingham) C++11
70 / 70
107 ms 10456 KB
#include<bits/stdc++.h>
using namespace std;
#define endl '\n';
typedef long long ll;
int N,M,Q,K;

int dp[100005];
vector<int> v[100005];
priority_queue<pair<int,int>, vector<pair<int,int> >,greater<pair<int,int> > > pq;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M >> Q >> K;
    for(int i = 0; i < 100005; i++) {
        dp[i] = INT_MAX;
    }
    for(int i = 0; i < Q; i++) {
        int x; cin >> x;
        dp[x] = 0;
        pq.push({0,x});
    }
    for(int i = 0; i < M; i++) {
        int a,b; cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    while(!pq.empty()) {
        int a = pq.top().first + 1;
        int b = pq.top().second;
        int x = 1;
        int k = K;
        while(a > k) {
            x++;
            k += x * K;
        }
        pq.pop();
        for(int i = 0; i < v[b].size(); i++) {
            if(dp[v[b][i]] > x) {
                dp[v[b][i]] = x;
                pq.push({a,v[b][i]});
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        cout << dp[i] << " ";
    }
    return 0;
}

Compilation message

birmingham.cpp: In function 'int main()':
birmingham.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i = 0; i < v[b].size(); i++) {
      |                        ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3056 KB Output is correct
3 Correct 2 ms 3056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 3 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3028 KB Output is correct
2 Correct 2 ms 3060 KB Output is correct
3 Correct 2 ms 3040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3144 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 2 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 3 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 2 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 2 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 7628 KB Output is correct
2 Correct 100 ms 10096 KB Output is correct
3 Correct 83 ms 10360 KB Output is correct
4 Correct 75 ms 9160 KB Output is correct
5 Correct 89 ms 9416 KB Output is correct
6 Correct 86 ms 10432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 7992 KB Output is correct
2 Correct 85 ms 10020 KB Output is correct
3 Correct 81 ms 10112 KB Output is correct
4 Correct 91 ms 10352 KB Output is correct
5 Correct 76 ms 9952 KB Output is correct
6 Correct 88 ms 9804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 7752 KB Output is correct
2 Correct 92 ms 10192 KB Output is correct
3 Correct 94 ms 10292 KB Output is correct
4 Correct 92 ms 10272 KB Output is correct
5 Correct 84 ms 9552 KB Output is correct
6 Correct 84 ms 9892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 7504 KB Output is correct
2 Correct 99 ms 9904 KB Output is correct
3 Correct 92 ms 10104 KB Output is correct
4 Correct 85 ms 9700 KB Output is correct
5 Correct 75 ms 9248 KB Output is correct
6 Correct 92 ms 9820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 7624 KB Output is correct
2 Correct 92 ms 9700 KB Output is correct
3 Correct 98 ms 9536 KB Output is correct
4 Correct 94 ms 9604 KB Output is correct
5 Correct 73 ms 9660 KB Output is correct
6 Correct 78 ms 9724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 7512 KB Output is correct
2 Correct 107 ms 9780 KB Output is correct
3 Correct 78 ms 9556 KB Output is correct
4 Correct 80 ms 9900 KB Output is correct
5 Correct 79 ms 9472 KB Output is correct
6 Correct 80 ms 9924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 7628 KB Output is correct
2 Correct 82 ms 9172 KB Output is correct
3 Correct 87 ms 10236 KB Output is correct
4 Correct 86 ms 9504 KB Output is correct
5 Correct 79 ms 9880 KB Output is correct
6 Correct 86 ms 10456 KB Output is correct