답안 #845206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845206 2023-09-06T12:35:46 Z vjudge1 Birmingham (COCI20_birmingham) C++17
35 / 70
127 ms 11148 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
#define int ll

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;
        if (x==0) {
            cout<<0<<" ";continue;
        }
        int start = k;
        int to = start;
        int amt = 1;
        while (x>to) {
            start*=2;
            to+=start;
            amt++;
        }
        cout<<amt<<" ";
    }cout<<endl;
    return 0;
}

Compilation message

birmingham.cpp: In function 'int32_t main()':
birmingham.cpp:38:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for (int i = 0; i<nodes[f].adj.size();i++) {
      |                         ~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 10424 KB Output is correct
2 Incorrect 116 ms 11092 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 11148 KB Output is correct
2 Incorrect 127 ms 11068 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 10584 KB Output is correct
2 Incorrect 116 ms 11092 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 10288 KB Output is correct
2 Incorrect 114 ms 10932 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 10236 KB Output is correct
2 Incorrect 101 ms 10580 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 10356 KB Output is correct
2 Incorrect 104 ms 10576 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 10536 KB Output is correct
2 Incorrect 91 ms 9940 KB Output isn't correct
3 Halted 0 ms 0 KB -