답안 #845155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845155 2023-09-06T12:18:54 Z vjudge1 Birmingham (COCI20_birmingham) C++17
70 / 70
79 ms 14716 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    #define OPEN freopen(".in", "r", stdin); \
                 freopen(".out", "w", stdout);
#else
    #define OPEN void(23);
#endif

void solve()
{
    int n, m, q, k; cin >> n >> m >> q >> k;
    vector <int> mans(q);
    for(int &i : mans) cin >> i;

    vector <int> adj[n +1];
    for(int i = 1; i <= m; i++)
    {
        int u, v; cin >> u >> v;
        adj[u].emplace_back(v);
        adj[v].emplace_back(u);
    }

    vector <int> cev(n +1, -1);
    queue <pair <int, int>> que;
    for(int &i : mans) que.emplace(i, 0);
    while(!que.empty())
    {
        auto [x, d] = que.front();
        que.pop();
        if(cev[x] != -1) continue;
        cev[x] = d;

        for(int &child : adj[x])
        {
            que.emplace(child, d +1);
        }
    }

    auto find = [&](int x) -> int
    {
        int _k = k;
        int i = 0, j = 0;
        while(j < x) i++, j += k, k += _k;
        k = _k;

        return i;
    };

    for(int i = 1; i <= n; i++) cout << find(cev[i]) << " ";

    return;
}

int32_t main()
{
    OPEN;

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1; //cin >> t;
    while(t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 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 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 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 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 0 ms 348 KB Output is correct
2 Correct 1 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 79 ms 11592 KB Output is correct
2 Correct 66 ms 12692 KB Output is correct
3 Correct 69 ms 13904 KB Output is correct
4 Correct 52 ms 10580 KB Output is correct
5 Correct 56 ms 10836 KB Output is correct
6 Correct 61 ms 14700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 12492 KB Output is correct
2 Correct 55 ms 12132 KB Output is correct
3 Correct 57 ms 13128 KB Output is correct
4 Correct 58 ms 12880 KB Output is correct
5 Correct 55 ms 12372 KB Output is correct
6 Correct 51 ms 13444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 11912 KB Output is correct
2 Correct 58 ms 12628 KB Output is correct
3 Correct 60 ms 13784 KB Output is correct
4 Correct 59 ms 12624 KB Output is correct
5 Correct 54 ms 11172 KB Output is correct
6 Correct 52 ms 13620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 11024 KB Output is correct
2 Correct 62 ms 11996 KB Output is correct
3 Correct 60 ms 13376 KB Output is correct
4 Correct 53 ms 11600 KB Output is correct
5 Correct 59 ms 10836 KB Output is correct
6 Correct 52 ms 13136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 10832 KB Output is correct
2 Correct 51 ms 11416 KB Output is correct
3 Correct 55 ms 12112 KB Output is correct
4 Correct 51 ms 11344 KB Output is correct
5 Correct 55 ms 11604 KB Output is correct
6 Correct 52 ms 12884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 10944 KB Output is correct
2 Correct 53 ms 11860 KB Output is correct
3 Correct 54 ms 12372 KB Output is correct
4 Correct 54 ms 11860 KB Output is correct
5 Correct 50 ms 11252 KB Output is correct
6 Correct 51 ms 13780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 11352 KB Output is correct
2 Correct 50 ms 10816 KB Output is correct
3 Correct 65 ms 13904 KB Output is correct
4 Correct 49 ms 11352 KB Output is correct
5 Correct 60 ms 11728 KB Output is correct
6 Correct 66 ms 14716 KB Output is correct