# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1019178 | Tri_Pahm | Birmingham (COCI20_birmingham) | C++14 | 60 ms | 10836 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Practice makes perfect
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0);
#define file "bmh"
#define ll long long
const int maxn = 1e5 + 5;
int n, m, q, ans[maxn], d[maxn];
ll k;
bool vis[maxn];
queue<int> qu;
vector<int> g[maxn];
void bfs() {
while (qu.size()) {
int u = qu.front();
qu.pop();
for (int i = 0; i < g[u].size(); ++i) {
int v = g[u][i];
if (!vis[v]) {
vis[v] = 1;
qu.push(v);
d[v] = d[u] + 1;
}
}
}
}
int main() {
fastIO
//freopen(file".inp", "r", stdin);
//freopen(file".out", "w", stdout);
cin >> n >> m >> q >> k;
for (int i = 1; i <= n; ++i)
ans[i] = INT_MAX;
for (int i = 1; i <= q; ++i) {
int x;
cin >> x;
qu.push(x);
vis[x] = 1;
d[x] = 0;
ans[x] = 0;
}
while (m--) {
int x, y;
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
bfs();
for (int i = 1; i <= n; ++i) {
if (!d[i])
continue;
int lo = 1, hi = n;
while (lo <= hi) {
ll mi = (lo + hi) >> 1;
if ((mi * (mi + 1) / 2) * k >= d[i]) {
ans[i] = min(ans[i], (int) mi);
hi = mi - 1;
}
else
lo = mi + 1;
}
}
for (int i = 1; i <= n; ++i)
cout << ans[i] << " ";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |