Submission #845167

# Submission time Handle Problem Language Result Execution time Memory
845167 2023-09-06T12:23:41 Z vjudge1 Birmingham (COCI20_birmingham) C++17
20 / 70
170 ms 8940 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pri pair<int,int>
#define prl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define vpl vector<pair<ll,ll>>
#define re return 0
#define sqrt sqrtl

struct node {
    int val;
    vector<int> adj;
    int length=1e9;
};

int32_t main() {
    int n,m,k,q;cin>>n>>m>>q>>k;
    queue<int> que;
    vector<node> nodes(n+1); 
    for (int i = 0;i<q;i++) {
        int x;cin>>x;
        que.push(x);
        nodes[x].length = 0;
    }
    for (int i = 0;i<m;i++ ){
        int a,b;cin>>a>>b;
        nodes[a].adj.push_back(b);
        nodes[b].adj.push_back(a);
    }
    while (que.size()) {
        auto f = que.front();
        for (int i = 0; i<nodes[f].adj.size();i++) {
            if(nodes[nodes[f].adj[i]].length > nodes[f].length+1) {
                nodes[nodes[f].adj[i]].length = nodes[f].length+1;
                que.push(nodes[f].adj[i]);
            }
        }
        que.pop();
    }

    for (int i = 1;i<=n;i++){
        int x = nodes[i].length;
        int res =ceil((-1 + sqrt(1+(8*x)/k)) / 2);
        cout<<res<<" ";
    }cout<<endl;
    return 0;
}

Compilation message

birmingham.cpp: In function 'int32_t main()':
birmingham.cpp:37:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int i = 0; i<nodes[f].adj.size();i++) {
      |                         ~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 508 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 121 ms 8532 KB Output is correct
2 Correct 144 ms 8732 KB Output is correct
3 Correct 145 ms 8940 KB Output is correct
4 Correct 104 ms 8268 KB Output is correct
5 Incorrect 136 ms 8532 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 8812 KB Output is correct
2 Correct 101 ms 8760 KB Output is correct
3 Correct 113 ms 8932 KB Output is correct
4 Correct 117 ms 8788 KB Output is correct
5 Incorrect 146 ms 8788 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 164 ms 8696 KB Output is correct
2 Correct 135 ms 8900 KB Output is correct
3 Correct 170 ms 8824 KB Output is correct
4 Correct 110 ms 8792 KB Output is correct
5 Incorrect 96 ms 8540 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 102 ms 8484 KB Output is correct
2 Correct 104 ms 8788 KB Output is correct
3 Correct 112 ms 8784 KB Output is correct
4 Correct 103 ms 8528 KB Output is correct
5 Incorrect 95 ms 8276 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 93 ms 8452 KB Output is correct
2 Correct 115 ms 8500 KB Output is correct
3 Correct 125 ms 8532 KB Output is correct
4 Correct 108 ms 8444 KB Output is correct
5 Incorrect 132 ms 8616 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 93 ms 8508 KB Output is correct
2 Correct 106 ms 8532 KB Output is correct
3 Correct 100 ms 8532 KB Output is correct
4 Correct 117 ms 8780 KB Output is correct
5 Incorrect 100 ms 8480 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 112 ms 8540 KB Output is correct
2 Correct 140 ms 8260 KB Output is correct
3 Correct 128 ms 8784 KB Output is correct
4 Correct 116 ms 8808 KB Output is correct
5 Incorrect 104 ms 8660 KB Output isn't correct
6 Halted 0 ms 0 KB -