답안 #885184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
885184 2023-12-09T07:45:06 Z vjudge1 Birmingham (COCI20_birmingham) C++17
0 / 70
69 ms 13128 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;
bool vis[N];

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

int bs(int x){
    
    int l=0, r=5e5, 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<p;i++){
        int x; cin>>x;
        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++){
        cout<<bs(dist[i])<<" ";
    }
}

int32_t main(){
    cin.tie(0)->sync_with_stdio(false);
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2648 KB Output is correct
3 Incorrect 1 ms 2648 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Incorrect 1 ms 2816 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Incorrect 1 ms 2652 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2816 KB Output is correct
3 Incorrect 1 ms 2652 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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
4 Incorrect 1 ms 2652 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Incorrect 1 ms 2652 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Incorrect 1 ms 2652 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 11860 KB Output is correct
2 Correct 60 ms 12804 KB Output is correct
3 Incorrect 66 ms 13128 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 12616 KB Output is correct
2 Correct 53 ms 12380 KB Output is correct
3 Incorrect 57 ms 12628 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 12116 KB Output is correct
2 Correct 57 ms 12828 KB Output is correct
3 Incorrect 57 ms 12972 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 11400 KB Output is correct
2 Correct 65 ms 12108 KB Output is correct
3 Incorrect 55 ms 12844 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 11312 KB Output is correct
2 Correct 54 ms 12012 KB Output is correct
3 Incorrect 50 ms 11856 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 11512 KB Output is correct
2 Correct 51 ms 12020 KB Output is correct
3 Incorrect 56 ms 11792 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 11600 KB Output is correct
2 Correct 46 ms 11056 KB Output is correct
3 Incorrect 69 ms 13036 KB Output isn't correct
4 Halted 0 ms 0 KB -