Submission #559419

# Submission time Handle Problem Language Result Execution time Memory
559419 2022-05-09T18:01:34 Z kappa Birmingham (COCI20_birmingham) C++14
0 / 70
245 ms 20908 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define st first
#define nd second
#define MOD 1000000007
typedef pair<ll, ll> pii;
typedef pair<pii, ll> piiq;

const ll maxn = 2e5 + 5;

ll n, m, qu, k, vis[maxn], ans[maxn];

vector<ll> v[maxn];

int main(){
    cin >> n >> m >> qu >> k;
    memset(ans, -1, sizeof(ans));
    queue<piiq> q;
    for (int i = 0; i < qu; i++)
    {
        ll a;
        cin >> a;
        q.push({{a, 0}, 1});
        ans[a] = 0;
    }
    for (int i = 0; i < m; i++)
    {
        ll y, u;
        cin >> y >> u;
        v[y].pb(u);
        v[u].pb(y);
    }

    while(!q.empty()){
        piiq curr = q.front();
        ll index = curr.st.st, dis = curr.st.nd, day = curr.nd;
        q.pop();

        if(vis[index]){
            continue;;
        }
        vis[index] = 1;

        cout << index << " " << dis << " " << day << "\n";

        if(dis > k){
            dis = 0;
            day++;
        }

        if(ans[index] == -1){
            ans[index] = day;
        }

        for (int i = 0; i < v[index].size(); i++)
        {
            ll next = v[index][i];
            q.push({{next, dis + 1}, day});
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cout << ans[i] << " ";
    }
}

Compilation message

birmingham.cpp: In function 'int main()':
birmingham.cpp:57:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for (int i = 0; i < v[index].size(); i++)
      |                         ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 6548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 245 ms 19480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 20908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 229 ms 19624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 18392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 185 ms 18644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 186 ms 18680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 233 ms 19240 KB Output isn't correct
2 Halted 0 ms 0 KB -