Submission #689630

#TimeUsernameProblemLanguageResultExecution timeMemory
689630WarinchaiBirmingham (COCI20_birmingham)C++14
15 / 70
97 ms13784 KiB
#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)

birmingham.cpp: In function 'int main()':
birmingham.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for(int i=0;i<v[a].size();i++){
      |               ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...