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;
const int N = 1e5+1;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m,s,k,i,j,a,b,dist[N],wave[N];
vector<int>adj[N];
cin>>n>>m>>s>>k;
memset(dist,-1,sizeof(dist));
queue<int>q;
for(i = 0; i < s; i++)
{
cin>>a;
q.push(a);
dist[a] = 0;
}
for(i = 0; i < m; i++)
{
cin>>a>>b;
adj[a].emplace_back(b);
adj[b].emplace_back(a);
}
while(q.size())
{
a = q.front();
q.pop();
for(int x:adj[a])
{
if(dist[x] == -1)
{
dist[x] = dist[a] + 1;
q.push(x);
}
}
}
wave[0] = 0;
int curr = 0, old = 0;
for(i = 1; curr < n; i++)
{
old = curr;
curr += k * i;
for(j = old + 1; j <= min(n,curr); j++)
wave[j] = i;
}
for(i=1;i<=n;i++)
cout<<wave[dist[i]]<<" \n"[i==n];
}
# | 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... |