답안 #845186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845186 2023-09-06T12:29:44 Z vjudge1 Birmingham (COCI20_birmingham) C++17
20 / 70
141 ms 9032 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 + ceil(sqrt(1+(8*x)/k))) / (float)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++) {
      |                         ~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 ms 496 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 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 8492 KB Output is correct
2 Correct 120 ms 8792 KB Output is correct
3 Correct 141 ms 8800 KB Output is correct
4 Correct 90 ms 8272 KB Output is correct
5 Incorrect 89 ms 8528 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 8800 KB Output is correct
2 Correct 102 ms 8728 KB Output is correct
3 Correct 120 ms 8788 KB Output is correct
4 Correct 108 ms 8964 KB Output is correct
5 Incorrect 113 ms 8660 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 110 ms 8628 KB Output is correct
2 Correct 121 ms 8988 KB Output is correct
3 Correct 122 ms 8788 KB Output is correct
4 Correct 110 ms 8804 KB Output is correct
5 Incorrect 95 ms 8532 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 8532 KB Output is correct
2 Correct 108 ms 8780 KB Output is correct
3 Correct 110 ms 8728 KB Output is correct
4 Correct 94 ms 8532 KB Output is correct
5 Incorrect 95 ms 8448 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 8732 KB Output is correct
2 Correct 126 ms 8528 KB Output is correct
3 Correct 102 ms 8532 KB Output is correct
4 Correct 108 ms 8436 KB Output is correct
5 Incorrect 122 ms 8508 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 8532 KB Output is correct
2 Correct 99 ms 8736 KB Output is correct
3 Correct 128 ms 8532 KB Output is correct
4 Correct 119 ms 8632 KB Output is correct
5 Incorrect 97 ms 8532 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 8564 KB Output is correct
2 Correct 90 ms 8272 KB Output is correct
3 Correct 131 ms 9032 KB Output is correct
4 Correct 125 ms 8596 KB Output is correct
5 Incorrect 101 ms 8532 KB Output isn't correct
6 Halted 0 ms 0 KB -