답안 #845193

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845193 2023-09-06T12:32:05 Z vjudge1 Birmingham (COCI20_birmingham) C++17
35 / 70
121 ms 11152 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, mod);
  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;

  vector<int> vis(n+1);
  for(int i = 0; i < q; i++){
    qq.push(st[i]);
    vis[st[i]] = 1;
  }

  while(!qq.empty()){
    int x = qq.front();
    qq.pop();

    for(auto itr: adj[x]){
        if(!vis[itr]){
            vis[itr] = 1;
            dis[itr] = 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 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 504 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 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 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 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 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
4 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 10580 KB Output is correct
2 Incorrect 115 ms 11088 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 10996 KB Output is correct
2 Incorrect 121 ms 10836 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 112 ms 10608 KB Output is correct
2 Incorrect 112 ms 11152 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 10264 KB Output is correct
2 Incorrect 121 ms 10872 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 10448 KB Output is correct
2 Incorrect 110 ms 10580 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 10356 KB Output is correct
2 Incorrect 100 ms 10532 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 10312 KB Output is correct
2 Incorrect 102 ms 10000 KB Output isn't correct
3 Halted 0 ms 0 KB -