답안 #845125

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845125 2023-09-06T12:07:24 Z vjudge1 Birmingham (COCI20_birmingham) C++17
15 / 70
78 ms 8936 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();

		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++) {
		int cnt = (dist[i] != 0);
		int k = dist[i] - K;
		while (k > 0) {
			cnt++;
			k -= K;
		}
		cout << cnt << " ";
	}
	cout << "\n"; 
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 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 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 8820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 8936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 8792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 8532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 8580 KB Output is correct
2 Incorrect 76 ms 8928 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 8532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 8676 KB Output isn't correct
2 Halted 0 ms 0 KB -