Submission #291720

# Submission time Handle Problem Language Result Execution time Memory
291720 2020-09-05T17:31:30 Z penguinhacker Birmingham (COCI20_birmingham) C++17
70 / 70
111 ms 10232 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

const int mxN=1e5;
int n, m, starts, k;
int d[mxN];
vector<int> adj[mxN];
queue<int> q;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m >> starts >> k;
	fill(d, d+n, -1);
	for (int i=0; i<starts; ++i) {
		int a; cin >> a, --a;
		d[a]=0;
		q.push(a);
	}
	for (int i=0; i<m; ++i) {
		int a, b; cin >> a >> b, --a, --b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	while(!q.empty()) {
		int u=q.front(); q.pop();
		for (int v : adj[u]) if (d[v]==-1) {
			d[v]=d[u]+1;
			q.push(v);
		}
	}
	for (int i=0; i<n; ++i) {
		int ans=0;
		for (int j=1; d[i]>0; ++j) {
			++ans;
			d[i]-=k*j;
		}
		cout << ans << " ";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2848 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 3 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 3 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 9464 KB Output is correct
2 Correct 109 ms 9972 KB Output is correct
3 Correct 111 ms 10232 KB Output is correct
4 Correct 84 ms 8952 KB Output is correct
5 Correct 94 ms 9208 KB Output is correct
6 Correct 103 ms 10232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 9848 KB Output is correct
2 Correct 95 ms 9720 KB Output is correct
3 Correct 101 ms 10024 KB Output is correct
4 Correct 103 ms 9976 KB Output is correct
5 Correct 102 ms 9720 KB Output is correct
6 Correct 85 ms 9592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 9592 KB Output is correct
2 Correct 105 ms 9976 KB Output is correct
3 Correct 105 ms 10232 KB Output is correct
4 Correct 104 ms 9976 KB Output is correct
5 Correct 105 ms 9336 KB Output is correct
6 Correct 91 ms 9592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 9080 KB Output is correct
2 Correct 110 ms 9848 KB Output is correct
3 Correct 102 ms 9976 KB Output is correct
4 Correct 91 ms 9520 KB Output is correct
5 Correct 84 ms 9080 KB Output is correct
6 Correct 91 ms 9592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 9192 KB Output is correct
2 Correct 97 ms 9512 KB Output is correct
3 Correct 91 ms 9464 KB Output is correct
4 Correct 106 ms 9400 KB Output is correct
5 Correct 90 ms 9464 KB Output is correct
6 Correct 83 ms 9468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 9208 KB Output is correct
2 Correct 101 ms 9688 KB Output is correct
3 Correct 87 ms 9488 KB Output is correct
4 Correct 94 ms 9720 KB Output is correct
5 Correct 89 ms 9336 KB Output is correct
6 Correct 88 ms 9720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 9440 KB Output is correct
2 Correct 86 ms 8952 KB Output is correct
3 Correct 105 ms 10232 KB Output is correct
4 Correct 100 ms 9324 KB Output is correct
5 Correct 94 ms 9592 KB Output is correct
6 Correct 104 ms 10232 KB Output is correct