Submission #845129

#TimeUsernameProblemLanguageResultExecution timeMemory
845129vjudge1Birmingham (COCI20_birmingham)C++14
70 / 70
245 ms13504 KiB
#include <bits/stdc++.h> using namespace std; void solve(void){ int n,m,q,k; cin >> n >> m >> q >> k; vector<int> insider(q); vector<vector<int>> komsu(n); for(int i=0; i<q; i++) cin >> insider[i]; for(int i=0; i<m; i++){ int a,b; cin >> a >> b; a--; b--; komsu[a].push_back(b); komsu[b].push_back(a); } vector<int> uzaklik(n,-1); priority_queue<pair<int,int>> pq; for(int i=0; i<q; i++){ pq.push({0, insider[i]-1}); } while(pq.size()){ int len = -pq.top().first; int node = pq.top().second; pq.pop(); if( uzaklik[node] != -1 ) continue; uzaklik[node] = len; for(int i=0; i<komsu[node].size(); i++){ pq.push({-len-1, komsu[node][i]}); } } for(int i=0; i<n; i++){ int len = ceil( ((double) uzaklik[i] )/ k ); cout << ceil( (-1 + sqrt(1+8*len))/2 ) << " "; } cout << "\n"; } int main(){ int t=1; // cin >> t; while(t--) solve(); return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'void solve()':
birmingham.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i=0; i<komsu[node].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...