답안 #845162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845162 2023-09-06T12:22:06 Z vjudge1 Birmingham (COCI20_birmingham) C++14
70 / 70
71 ms 9556 KB
// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 1e5 + 5;
vector<int> adj[N];
int vis[N], ans[N];
inline void solve(){
    int n, m, q, k;
    cin >> n >> m >> q >> k;
    int a[q];
    for(int i = 0; i < q; i++){
        cin >> a[i];
    }
    for(int i = 0, x, y; i < m; i++){
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    queue<pair<int, int> > Q;
    for(int i = 0; i < q; i++){
        Q.push({a[i], 0});
        vis[a[i]] = 1;
    }
    while(!Q.empty()){
        int node = Q.front().ff, step = Q.front().ss;
        Q.pop();
        ans[node] = step;
        for(int i = 0; i < adj[node].sz; i++){
            if(!vis[adj[node][i]]){
                vis[adj[node][i]] = 1;
                Q.push({adj[node][i], step+1});
            }
        }
    }
    for(int i = 1; i <= n; i++){
        int cnt = 0, carp = 1, sum = 0;
        while(sum < ans[i]){
            cnt++;
            sum += carp * k;
            carp++;
        }
        cout << cnt << " ";
    }
}
int main(){
    fast_io
    int t;
    t = 1;
    while(t--) solve();
}

Compilation message

birmingham.cpp: In function 'void solve()':
birmingham.cpp:42:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for(int i = 0; i < adj[node].sz; i++){
      |                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3172 KB Output is correct
3 Correct 1 ms 3160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3416 KB Output is correct
2 Correct 1 ms 3164 KB Output is correct
3 Correct 1 ms 3160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3160 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3408 KB Output is correct
2 Correct 1 ms 3164 KB Output is correct
3 Correct 1 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3164 KB Output is correct
2 Correct 2 ms 3408 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 1 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Correct 1 ms 3164 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3160 KB Output is correct
3 Correct 1 ms 3164 KB Output is correct
4 Correct 1 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 9300 KB Output is correct
2 Correct 54 ms 8276 KB Output is correct
3 Correct 49 ms 8528 KB Output is correct
4 Correct 44 ms 7760 KB Output is correct
5 Correct 48 ms 7740 KB Output is correct
6 Correct 49 ms 8596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 9556 KB Output is correct
2 Correct 48 ms 8276 KB Output is correct
3 Correct 48 ms 8440 KB Output is correct
4 Correct 71 ms 8232 KB Output is correct
5 Correct 56 ms 8276 KB Output is correct
6 Correct 48 ms 8276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 9192 KB Output is correct
2 Correct 49 ms 8292 KB Output is correct
3 Correct 50 ms 8536 KB Output is correct
4 Correct 54 ms 8360 KB Output is correct
5 Correct 55 ms 8020 KB Output is correct
6 Correct 50 ms 8376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 9008 KB Output is correct
2 Correct 64 ms 8016 KB Output is correct
3 Correct 53 ms 8348 KB Output is correct
4 Correct 53 ms 7936 KB Output is correct
5 Correct 52 ms 7808 KB Output is correct
6 Correct 44 ms 8228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 8988 KB Output is correct
2 Correct 48 ms 9244 KB Output is correct
3 Correct 48 ms 8144 KB Output is correct
4 Correct 44 ms 7780 KB Output is correct
5 Correct 56 ms 8152 KB Output is correct
6 Correct 63 ms 8284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 9176 KB Output is correct
2 Correct 50 ms 8092 KB Output is correct
3 Correct 57 ms 8224 KB Output is correct
4 Correct 47 ms 8128 KB Output is correct
5 Correct 55 ms 7816 KB Output is correct
6 Correct 50 ms 8504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 9172 KB Output is correct
2 Correct 51 ms 7768 KB Output is correct
3 Correct 59 ms 8452 KB Output is correct
4 Correct 47 ms 7852 KB Output is correct
5 Correct 52 ms 7996 KB Output is correct
6 Correct 61 ms 8680 KB Output is correct