답안 #845133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845133 2023-09-06T12:11:34 Z vjudge1 Birmingham (COCI20_birmingham) C++17
15 / 70
67 ms 8148 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 20;
const ll MAXN = 1e5 + 5;

vector<vector<int>> graph;
int vis[MAXN], dist[MAXN];
int main() {
	fast
	int N, M, Q, K;
	cin >> N >> M >> Q >> K;

	for (int i = 1; i <= N; i++)
		dist[i] = 1e8;

	queue<int> q;
	for (int i = 0; i < Q; i++) {
		int x; cin >> x;
		q.push(x);
		dist[x] = 0;
	}

	graph = vector<vector<int>>(N+1, vector<int>());
	while (M--) {
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	while (!q.empty()) {
		int node = q.front();
		q.pop();
		vis[node] = true;

		for (auto u : graph[node]) {
			if (!vis[u] && dist[u] > dist[node] + 1) {
				dist[u] = dist[node] + 1;
				q.push(u);
			}
		}
	}

	for (int i = 1; i <= N; i++) {
		cout << (dist[i] + K - 1) / K << " "; 
	}
	cout << "\n"; 
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 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 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 7960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 8148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 7760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 7760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 7704 KB Output is correct
2 Incorrect 64 ms 7872 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 7760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 8032 KB Output isn't correct
2 Halted 0 ms 0 KB -