Submission #693981

# Submission time Handle Problem Language Result Execution time Memory
693981 2023-02-03T13:45:27 Z Gital Birmingham (COCI20_birmingham) C++11
5 / 70
126 ms 10164 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++) {
      |                        ~~^~~~~~~~~~~~~
birmingham.cpp:14:15: warning: iteration 100005 invokes undefined behavior [-Waggressive-loop-optimizations]
   14 |         dp[i] = INT_MAX;
      |               ^
birmingham.cpp:13:22: note: within this loop
   13 |     for(int i = 0; i <= 100005; i++) {
      |                    ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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
4 Correct 2 ms 3060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Incorrect 2 ms 3060 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 119 ms 9672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 10164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 84 ms 9800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 9420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 9420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 9464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 9532 KB Output isn't correct
2 Halted 0 ms 0 KB -