Submission #845437

# Submission time Handle Problem Language Result Execution time Memory
845437 2023-09-06T13:37:08 Z vjudge1 Birmingham (COCI20_birmingham) C++17
70 / 70
80 ms 10772 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define int long long
#define pb push_back
#define lim 300000
#define till 40001
// # of primes till 1e6 = 7e4
using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
using pii = array<int,2>;

const int mod=1000000007ll;

void solve(){
    int n,m,Q,k;
    cin>>n>>m>>Q>>k;
    queue<int>q;
    int vis[n];
    memset(vis,-1,sizeof(vis));
    for(int i=0;i<Q;i++){
        int tem;
        cin>>tem;
        tem--;
        q.push(tem);
        vis[tem]=0;
    }
    vector<int>v[n];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    //cerr<<v[2].size()<<"\n";
    while(q.size()){
        int top=q.front();
        q.pop();
        //cerr<<top<<" doing\n";
        for(int i:v[top]){
            if(vis[i]==-1){
                //cerr<<i<<" "<<vis[i]<<" ";
                vis[i]=vis[top]+1;
                q.push(i);
            }
        }
    }
    vector<int>days;
    days.pb(0);
    int now=k;
    for(int i=2;*days.rbegin()<n;i++){
        days.pb(*days.rbegin()+now);
        //cerr<<*days.rbegin()<<"\n";
        now+=k;
    }
    //cerr<<"ok\n";
    for(int i=0;i<n;i++){
        //cerr<<vis[i]<<" "<<*days.rbegin()<<"\n";
        cout<<lower_bound(days.begin(),days.end(),vis[i])-days.begin()<<" ";
    }
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
#ifndef INTERACTIVE
    freopen("in","r",stdin);
#endif
    freopen("out","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 9808 KB Output is correct
2 Correct 55 ms 10384 KB Output is correct
3 Correct 74 ms 10772 KB Output is correct
4 Correct 46 ms 9176 KB Output is correct
5 Correct 47 ms 9552 KB Output is correct
6 Correct 57 ms 10320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 10208 KB Output is correct
2 Correct 54 ms 10064 KB Output is correct
3 Correct 80 ms 10276 KB Output is correct
4 Correct 57 ms 10320 KB Output is correct
5 Correct 52 ms 10024 KB Output is correct
6 Correct 59 ms 9552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 9808 KB Output is correct
2 Correct 59 ms 10312 KB Output is correct
3 Correct 70 ms 10284 KB Output is correct
4 Correct 57 ms 10320 KB Output is correct
5 Correct 49 ms 9524 KB Output is correct
6 Correct 50 ms 9556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 9296 KB Output is correct
2 Correct 53 ms 10064 KB Output is correct
3 Correct 59 ms 10320 KB Output is correct
4 Correct 55 ms 9808 KB Output is correct
5 Correct 47 ms 9304 KB Output is correct
6 Correct 49 ms 9552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 9552 KB Output is correct
2 Correct 51 ms 9808 KB Output is correct
3 Correct 62 ms 9560 KB Output is correct
4 Correct 49 ms 9544 KB Output is correct
5 Correct 49 ms 9812 KB Output is correct
6 Correct 49 ms 9552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 9552 KB Output is correct
2 Correct 59 ms 10284 KB Output is correct
3 Correct 49 ms 9552 KB Output is correct
4 Correct 54 ms 10064 KB Output is correct
5 Correct 54 ms 9504 KB Output is correct
6 Correct 50 ms 9816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 9552 KB Output is correct
2 Correct 55 ms 9296 KB Output is correct
3 Correct 57 ms 10448 KB Output is correct
4 Correct 49 ms 9560 KB Output is correct
5 Correct 51 ms 9852 KB Output is correct
6 Correct 57 ms 10264 KB Output is correct