# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238422 | stev2005 | Birmingham (COCI20_birmingham) | C++17 | 138 ms | 8532 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<vector>
#include<queue>
#include<cstdio>
using namespace std;
const int MAXN=(1<<17);
int n,m,q1,k;
int q_el[MAXN],used[MAXN];
vector<int>v[MAXN];
void read()
{
scanf("%d%d%d%d",&n,&m,&q1,&k);
for(int i=0;i<q1;i++)
scanf("%d",&q_el[i]);
int x,y;
for(int i=0;i<m;i++)
{
scanf("%d%d",&x,&y);
v[x].push_back(y);
v[y].push_back(x);
}
}
void BFS()
{
queue<int>q;
int w,nb,i,sz;
for(int i=0;i<q1;i++)
{
q.push(q_el[i]);
used[q_el[i]]=1;
}
while(!q.empty())
{
w=q.front();
q.pop();
sz=v[w].size();
for(i=0;i<sz;i++)
{
nb=v[w][i];
if(!used[nb])
{
used[nb]=used[w]+1;
q.push(nb);
}
}
}
}
void ans()
{
int rez;
for(int i=1;i<=n;i++)
{
rez=used[i]-1;
rez=(rez%k)?rez/k+1:rez/k;
printf("%d ",rez);
}
}
int main()
{
read();
BFS();
ans();
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... |