# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
213238 | Dremix10 | Birmingham (COCI20_birmingham) | C++17 | 276 ms | 11384 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 main (){
int n,m,q,k;
cin>>n>>m>>q>>k;
int sources[q];
int i;
for(i=0;i<q;i++)
cin>>sources[i];
vector <vector <int> > a(n+1,vector<int>());
for(i=0;i<m;i++){
int x,y;
cin>>x>>y;
a[x].push_back(y);
a[y].push_back(x);
}
/*
int j;
for(i=1;i<=n;i++){
cout<<i<<" -> ";
for(j=0;j<a[i].size();j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
*/
vector <int> d(n+1,1000000000);
queue <int> qu;
for(i=0;i<q;i++){
d[sources[i]]=0;
qu.push(sources[i]);
}
while(!qu.empty()){
int start=qu.front();
qu.pop();
for(i=0;i<a[start].size();i++){
if(d[a[start][i]]>d[start]+1){
d[a[start][i]]=d[start]+1;
qu.push(a[start][i]);
}
}
}
int fix[200000];
memset(fix,0,sizeof(fix));
long long curr=1;
long long next=1;
long long counter=0;
fix[0]=0;
for(i=1;i<200000;i++){
fix[i]=curr;
counter++;
if(counter==next){
curr++;
next++;
counter=0;
}
}
for(i=1;i<=n;i++){
int ans=d[i]/k;
if(d[i]%k>0)
ans++;
cout<<fix[ans]<<" ";
}
//cout<<endl;
//for(i=1;i<=n;i++)
// cout<<d[i]<<" ";
}
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... |