답안 #845105

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845105 2023-09-06T11:58:42 Z vjudge1 Birmingham (COCI20_birmingham) C++17
70 / 70
79 ms 11244 KB
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define spc << " " <<
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007

using namespace std;





void solve(){
    int n,m,q,k; cin >> n >> m >> q >> k;
    vi edges[n+1];
    int dist[n+1], vis[n+1];
    for(int i=1; i<=n; i++){
        dist[i]=-1;
        vis[i]=0;
    }
    queue<int> que;
    for(int i=1; i<=q; i++){
        int a; cin >> a;
        que.push(a);
        dist[a]=0;
        vis[a]=1;
    }
    for(int i=1; i<=m; i++){
        int a,b; cin >> a >> b;
        edges[a].pb(b);
        edges[b].pb(a);
    }

    while(que.size()>0){
        int f=que.front();
        que.pop();
        vis[f]=1;
        for(auto nex:edges[f]){
            if(vis[nex]) continue;
            vis[nex]=1;
            //cerr << f spc nex << endl;
            que.push(nex);
            dist[nex]=dist[f]+1;
        }
    }

    for(int i=1; i<=n; i++){
        int ans=0;
        int cur=1;
        //cerr << dist[i] << endl;
        while(dist[i]>=(cur*k)){
            dist[i]-=(cur*k);
            ans++;
            cur++;
        }
        if(dist[i]!=0) ans++;
        cout << ans << " ";
    }
}



signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out","w",stdout);
    #endif
    

    ll t=1;
    //cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 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 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 1 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 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 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 344 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 52 ms 10428 KB Output is correct
2 Correct 58 ms 11092 KB Output is correct
3 Correct 57 ms 11092 KB Output is correct
4 Correct 47 ms 10064 KB Output is correct
5 Correct 48 ms 10320 KB Output is correct
6 Correct 58 ms 11092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 11052 KB Output is correct
2 Correct 55 ms 10836 KB Output is correct
3 Correct 79 ms 10832 KB Output is correct
4 Correct 60 ms 11092 KB Output is correct
5 Correct 58 ms 10832 KB Output is correct
6 Correct 47 ms 10320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 10588 KB Output is correct
2 Correct 58 ms 11124 KB Output is correct
3 Correct 57 ms 11088 KB Output is correct
4 Correct 57 ms 11072 KB Output is correct
5 Correct 66 ms 10640 KB Output is correct
6 Correct 50 ms 10548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 10064 KB Output is correct
2 Correct 56 ms 10840 KB Output is correct
3 Correct 59 ms 11124 KB Output is correct
4 Correct 54 ms 10500 KB Output is correct
5 Correct 49 ms 10068 KB Output is correct
6 Correct 50 ms 10252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 10320 KB Output is correct
2 Correct 52 ms 10560 KB Output is correct
3 Correct 52 ms 10420 KB Output is correct
4 Correct 54 ms 10392 KB Output is correct
5 Correct 49 ms 10576 KB Output is correct
6 Correct 51 ms 10320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 10392 KB Output is correct
2 Correct 63 ms 10640 KB Output is correct
3 Correct 59 ms 10228 KB Output is correct
4 Correct 53 ms 10832 KB Output is correct
5 Correct 53 ms 10324 KB Output is correct
6 Correct 53 ms 10580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 10692 KB Output is correct
2 Correct 48 ms 10064 KB Output is correct
3 Correct 60 ms 11244 KB Output is correct
4 Correct 48 ms 10440 KB Output is correct
5 Correct 55 ms 10756 KB Output is correct
6 Correct 60 ms 11092 KB Output is correct