Submission #693987

#TimeUsernameProblemLanguageResultExecution timeMemory
693987GitalBirmingham (COCI20_birmingham)C++11
70 / 70
107 ms10456 KiB
#include<bits/stdc++.h> using namespace std; #define endl '\n'; typedef long long ll; int N,M,Q,K; int dp[100005]; vector<int> v[100005]; priority_queue<pair<int,int>, vector<pair<int,int> >,greater<pair<int,int> > > pq; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> N >> M >> Q >> K; for(int i = 0; i < 100005; i++) { dp[i] = INT_MAX; } for(int i = 0; i < Q; i++) { int x; cin >> x; dp[x] = 0; pq.push({0,x}); } for(int i = 0; i < M; i++) { int a,b; cin >> a >> b; v[a].push_back(b); v[b].push_back(a); } while(!pq.empty()) { int a = pq.top().first + 1; int b = pq.top().second; int x = 1; int k = K; while(a > k) { x++; k += x * K; } pq.pop(); for(int i = 0; i < v[b].size(); i++) { if(dp[v[b][i]] > x) { dp[v[b][i]] = x; pq.push({a,v[b][i]}); } } } for(int i = 1; i <= N; i++) { cout << dp[i] << " "; } return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'int main()':
birmingham.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i = 0; i < v[b].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...