# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
257940 | MrRobot_28 | Birmingham (COCI20_birmingham) | C++17 | 282 ms | 10616 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.
#include<bits/stdc++.h>
using namespace std;
signed main() {
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// cout.tie(NULL);
int n, m, q, k;
cin >> n >> m >> q >> k;
vector <int> dist(n, 1e9);
queue <int> Q;
for(int i = 0; i < q; i++)
{
int a;
cin >> a;
a--;
dist[a] = 0;
Q.push(a);
}
vector <vector <int> > g(n);
for(int i = 0; i < m; i++)
{
int a, b;
cin >> a >> b;
a--;
b--;
g[a].push_back(b);
g[b].push_back(a);
}
vector <int> ans(n, 0);
for(int i = 1;; i++)
{
while(Q.size() > 0 && dist[Q.front()] < i * (i + 1) / 2 * k)
{
int v = Q.front();
Q.pop();
for(int j = 0; j < g[v].size(); j++)
{
int to = g[v][j];
if(dist[to] > dist[v] + 1)
{
ans[to] = i;
dist[to] = dist[v] + 1;
Q.push(to);
}
}
}
if(Q.size() == 0)
{
break;
}
}
for(int i = 0; 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... |