# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238702 | TrayanaG | Birmingham (COCI20_birmingham) | C++14 | 273 ms | 11128 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;
int n,m,q,k;
int a[200020];
int used[200020];
vector <int> v[200020];
int br = 0;
queue<int>g;
void read()
{
memset(used, -1, sizeof(used));
cin>>n>>m>>q>>k;
for(int i=1; i<=q; i++)
{
cin>>a[i];
used[a[i]] = 0;
g.push(a[i]);
}
int x,y;
for(int i=1; i<=m; i++)
{
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
}
void BFS()
{
while(!g.empty())
{
int w = g.front();
g.pop();
int nb;
int sz = v[w].size();
for(int j=0; j<sz; j++)
{
nb = v[w][j];
if(used[nb]==-1)
{
used[nb] = used[w]+1;
g.push(nb);
}
}
}
}
int answer[200500];
int main()
{
read();
BFS();
int k1 = k;
for(int j=1; j<=200000; j++)
{
int lamp=0;
for(int i=1; i<=n; i++)
{
if(used[i]>0)
{
lamp = 1;
used[i]-=j*k;
if(used[i]<=0)answer[i] = j;
}
}
if(lamp==0)break;
}
cout<<answer[1];
for(int i=2; i<=n; i++)
{
cout<<" "<<answer[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... |