Submission #693990

# Submission time Handle Problem Language Result Execution time Memory
693990 2023-02-03T14:01:15 Z Gital Birmingham (COCI20_birmingham) C++11
70 / 70
130 ms 8264 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); cout.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++) {
      |                        ~~^~~~~~~~~~~~~
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 3 ms 3056 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3064 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3056 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3060 KB Output is correct
2 Correct 2 ms 3028 KB Output is correct
3 Correct 2 ms 2980 KB Output is correct
4 Correct 2 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3060 KB Output is correct
2 Correct 2 ms 3060 KB Output is correct
3 Correct 2 ms 3064 KB Output is correct
4 Correct 2 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 3056 KB Output is correct
3 Correct 2 ms 3028 KB Output is correct
4 Correct 2 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 7804 KB Output is correct
2 Correct 130 ms 8228 KB Output is correct
3 Correct 88 ms 8120 KB Output is correct
4 Correct 70 ms 7672 KB Output is correct
5 Correct 72 ms 7880 KB Output is correct
6 Correct 87 ms 8168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 8080 KB Output is correct
2 Correct 79 ms 8080 KB Output is correct
3 Correct 92 ms 8024 KB Output is correct
4 Correct 101 ms 8232 KB Output is correct
5 Correct 123 ms 8104 KB Output is correct
6 Correct 83 ms 7884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 7884 KB Output is correct
2 Correct 99 ms 8220 KB Output is correct
3 Correct 91 ms 8152 KB Output is correct
4 Correct 84 ms 8264 KB Output is correct
5 Correct 76 ms 7812 KB Output is correct
6 Correct 82 ms 7864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 7912 KB Output is correct
2 Correct 100 ms 8104 KB Output is correct
3 Correct 90 ms 8120 KB Output is correct
4 Correct 81 ms 7912 KB Output is correct
5 Correct 69 ms 7768 KB Output is correct
6 Correct 80 ms 7792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 7624 KB Output is correct
2 Correct 83 ms 7956 KB Output is correct
3 Correct 77 ms 7736 KB Output is correct
4 Correct 97 ms 7912 KB Output is correct
5 Correct 95 ms 7956 KB Output is correct
6 Correct 77 ms 7876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 7752 KB Output is correct
2 Correct 89 ms 8004 KB Output is correct
3 Correct 75 ms 7792 KB Output is correct
4 Correct 87 ms 8080 KB Output is correct
5 Correct 78 ms 7804 KB Output is correct
6 Correct 89 ms 7844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 7756 KB Output is correct
2 Correct 81 ms 7728 KB Output is correct
3 Correct 89 ms 8112 KB Output is correct
4 Correct 75 ms 7868 KB Output is correct
5 Correct 82 ms 8012 KB Output is correct
6 Correct 122 ms 8156 KB Output is correct