# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
689630 | Warinchai | Birmingham (COCI20_birmingham) | C++14 | 97 ms | 13784 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;
queue<pair<int,int> >q;
vector<int>v[100000];
int path[100005];
int main(){
int n,m,nn,k;
cin>>n>>m>>nn>>k;
for(int i=1;i<=n;i++){
path[i]=INT_MAX;
}
for(int i=0;i<nn;i++){
int a;
cin>>a;
q.push({a,0});
path[a]=0;
}
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
//cout<<"info\n";
while(!q.empty()){
int a=q.front().first;
int b=q.front().second;
//cout<<a<<" "<<b<<endl;
q.pop();
for(int i=0;i<v[a].size();i++){
if(b+1<path[v[a][i]]){
path[v[a][i]]=b+1;
q.push({v[a][i],b+1});
}
}
}
for(int i=1;i<=n;i++){
int r=path[i]%k;
if(r!=0){
cout<<path[i]/k+1<<" ";
}else{
cout<<path[i]/k<<" ";
}
}
}
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... |