# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
845203 | vjudge1 | Birmingham (COCI20_birmingham) | C++17 | 110 ms | 8912 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 <iostream>
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pri pair<int,int>
#define prl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define vpl vector<pair<ll,ll>>
#define re return 0
#define sqrt sqrtl
struct node {
int val;
vector<int> adj;
int length=1e9;
};
int32_t main() {
int n,m,k,q;cin>>n>>m>>q>>k;
queue<int> que;
vector<node> nodes(n+1);
for (int i = 0;i<q;i++) {
int x;cin>>x;
que.push(x);
nodes[x].length = 0;
}
for (int i = 0;i<m;i++ ){
int a,b;cin>>a>>b;
nodes[a].adj.push_back(b);
nodes[b].adj.push_back(a);
}
while (que.size()) {
auto f = que.front();
for (int i = 0; i<nodes[f].adj.size();i++) {
if(nodes[nodes[f].adj[i]].length > nodes[f].length+1) {
nodes[nodes[f].adj[i]].length = nodes[f].length+1;
que.push(nodes[f].adj[i]);
}
}
que.pop();
}
for (int i = 1;i<=n;i++){
int x = nodes[i].length;
if (x==0) {
cout<<0<<" ";continue;
}
int start = k;
int to = start;
int amt = 1;
while (x>to) {
start*=2;
to+=start;
amt++;
}
cout<<amt<<" ";
}cout<<endl;
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... |