답안 #845182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845182 2023-09-06T12:28:40 Z vjudge1 Birmingham (COCI20_birmingham) C++17
35 / 70
112 ms 11088 KB
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define int long long
using namespace std;

const int inf = 2e18 + 5;
const int N = 5e3 + 5;
const int mod = 998244353;

int32_t main(){
  //freopen("in.txt","r", stdin);
  int n, m, q, k;
  cin>>n>>m>>q>>k;
  vector<int> st(q);
  vector<int> dis(n+1, inf);
  for(int i = 0; i < q; i++){
    cin>>st[i];
    dis[st[i]] = 0;
  }
  vector<int> adj[n+1];
  for(int i = 0; i < m; i++){
    int u, v;
    cin>>u>>v;
    adj[u].pb(v);
    adj[v].pb(u);
  }

  queue<int> qq;

  for(int i = 0; i < q; i++){
    qq.push(st[i]);
  }

  vector<int> vis(n+1);
  while(!qq.empty()){
    int x = qq.front();
    qq.pop();

    for(auto itr: adj[x]){
        if(!vis[itr]){
            vis[itr] = 1;
            dis[itr] = min(dis[x] + 1, dis[itr]);
            //cout<<itr<<" "<<dis[itr]<<endl;
            qq.push(itr);
        }
    }
  }

  for(int i = 1; i <= n; i++){
    int x = dis[i], ans = 0, kk = k;
    while(x > 0){
        x -= kk;
        kk *= 2;
        ans++;
    }
    cout<<ans<<" ";
  }
  cout<<endl;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 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 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 10576 KB Output is correct
2 Incorrect 108 ms 11088 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 11088 KB Output is correct
2 Incorrect 107 ms 10832 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 10576 KB Output is correct
2 Incorrect 112 ms 11088 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 10476 KB Output is correct
2 Incorrect 103 ms 10832 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 10320 KB Output is correct
2 Incorrect 110 ms 10576 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 10320 KB Output is correct
2 Incorrect 105 ms 10576 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 10420 KB Output is correct
2 Incorrect 96 ms 10032 KB Output isn't correct
3 Halted 0 ms 0 KB -