# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238700 | Niya_R | Birmingham (COCI20_birmingham) | C++14 | 265 ms | 9252 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;
vector<int>v[100004];
queue<int>q1;
int used[100004];
int ans[100004];
void bfs()
{
while(!q1.empty())
{
int x=q1.front();
q1.pop();
int sz=v[x].size();
for(int i=0;i<sz;i++)
{
int nb=v[x][i];
if(used[nb]==-1)
{
used[nb]=used[x]+1;
q1.push(nb);
}
}
}
}
int main()
{
int n, m, q, k;
cin>>n>>m>>q>>k;
memset(used,-1,sizeof(used));
for(int i=1; i<=q; i++)
{
int x;
cin>>x;
used[x]=0;
ans[x]=0;
q1.push(x);
}
for(int i=1; i<=m; i++)
{
int x,y;
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
bfs();
int br=q;
for(int i=1;i<=200000;i++)
{
int l=0;
for(int j=1;j<=n;j++)
{
if(used[j]>0)
{
l=1;
used[j]-=i*k;
if(used[j]<=0) ans[j]=i;
}
}
if(l==0) break;
}
for(int i=1;i<=n;i++)
cout<<ans[i]<<" ";
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... |