답안 #845232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845232 2023-09-06T12:42:38 Z vjudge1 Birmingham (COCI20_birmingham) C++17
70 / 70
138 ms 11348 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;
        int s = 0;
        int ta = 1;
        while (s*k < x) {
            s+=ta++;
        }
        cout<<ta-1<<" ";
    }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 348 KB Output is correct
2 Correct 1 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 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 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 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
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 105 ms 10668 KB Output is correct
2 Correct 116 ms 11092 KB Output is correct
3 Correct 138 ms 11252 KB Output is correct
4 Correct 94 ms 10068 KB Output is correct
5 Correct 96 ms 10248 KB Output is correct
6 Correct 125 ms 11088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 128 ms 11092 KB Output is correct
2 Correct 127 ms 11004 KB Output is correct
3 Correct 123 ms 10836 KB Output is correct
4 Correct 115 ms 11092 KB Output is correct
5 Correct 105 ms 10972 KB Output is correct
6 Correct 108 ms 10384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 112 ms 10576 KB Output is correct
2 Correct 118 ms 11052 KB Output is correct
3 Correct 122 ms 11088 KB Output is correct
4 Correct 133 ms 11348 KB Output is correct
5 Correct 120 ms 10444 KB Output is correct
6 Correct 111 ms 10320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 10436 KB Output is correct
2 Correct 124 ms 10684 KB Output is correct
3 Correct 117 ms 11092 KB Output is correct
4 Correct 101 ms 10576 KB Output is correct
5 Correct 104 ms 10292 KB Output is correct
6 Correct 115 ms 10544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 10320 KB Output is correct
2 Correct 107 ms 10492 KB Output is correct
3 Correct 111 ms 10356 KB Output is correct
4 Correct 111 ms 10696 KB Output is correct
5 Correct 105 ms 10496 KB Output is correct
6 Correct 106 ms 10140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 10180 KB Output is correct
2 Correct 134 ms 10608 KB Output is correct
3 Correct 106 ms 10368 KB Output is correct
4 Correct 130 ms 10836 KB Output is correct
5 Correct 106 ms 10376 KB Output is correct
6 Correct 133 ms 10624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 10324 KB Output is correct
2 Correct 112 ms 10064 KB Output is correct
3 Correct 125 ms 11084 KB Output is correct
4 Correct 106 ms 10500 KB Output is correct
5 Correct 106 ms 10576 KB Output is correct
6 Correct 127 ms 11056 KB Output is correct