# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238541 | Salito | Birmingham (COCI20_birmingham) | C++14 | 270 ms | 9272 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;
int const maxn = 100005;
int n,m,q,k;
int a[maxn];
vector<int>v[maxn];
void read()
{
int i;
cin>>n>>m>>q>>k;
for(i=0;i<q;i++)
cin>>a[i];
int x,y;
for(i=0;i<m;i++)
{
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
}
int ans[maxn];
void bfs_solve()
{
queue<int>l;
int i,sz;
for(i=0;i<q;i++)
{
l.push(a[i]);
ans[a[i]] = 1;
}
while(!l.empty())
{
int t = l.front();
l.pop();
sz = v[t].size();
for(i=0;i<sz;i++)
{
int nb = v[t][i];
if(!ans[nb])
{
ans[nb] = ans[t]+1;
l.push(nb);
}
}
}
}
int get_ans(int x)
{
if(x == 1)
return 0;
int t;
x--;
int i = 1;
while(x - i*k > 0)
{
x-=i*k;
i++;
}
return i;
}
void print()
{
int i;
for(i=1;i<=n;i++)
cout<<get_ans(ans[i])<<" ";
cout<<endl;
}
int main()
{
read();
bfs_solve();
print();
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... |