Submission #885407

# Submission time Handle Problem Language Result Execution time Memory
885407 2023-12-09T15:21:51 Z vjudge1 Birmingham (COCI20_birmingham) C++17
20 / 70
59 ms 12368 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define endl '\n'
using namespace std;
const int N = 1e5 + 5;

int n,m,p,k,dist[N];
vector<int> g[N];
queue<int> q;

void bfs(){
    while(!q.empty()){
        int x=q.front(); q.pop();
        
        for(auto go: g[x]){
            if(dist[x]+1<dist[go]){
                dist[go]=dist[x]+1;
                q.push(go);
                //cout<<go<<" from "<<x<<" with "<<dist[go]<<endl;
            }
        }
    }
}

int bs(int x){
    
    int l=0, r=1e9, ans=-1;
    while(l<=r){
        int m=l+(r-l)/2;
        
        if(m*(m+1)*k/2 >= x ){
            ans=m;
            r=m-1;
        }
        else
            l=m+1;
    }
    return ans;
}

void solve(){
    cin>>n>>m>>p>>k;
    for(int i=0;i<=n;i++) dist[i]=1e12;
    for(int i=0;i<p;i++){
        int x; cin>>x;
        dist[x]=true;
        q.push(x);
    }
    for(int i=0;i<m;i++){
        int a,b; cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    
    bfs();
    
    for(int i=1;i<=n;i++){
        int ans=0;
        int omg=k;
        while(dist[i]>omg){
            ans++;
            omg+=ans*k;
        }
        cout<<ans<<" ";
    }
}

int32_t main(){
    cin.tie(0)->sync_with_stdio(false);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2820 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 11876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 12368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 11860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 11300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 11344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 11296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 11600 KB Output isn't correct
2 Halted 0 ms 0 KB -