Submission #559419

#TimeUsernameProblemLanguageResultExecution timeMemory
559419kappaBirmingham (COCI20_birmingham)C++14
0 / 70
245 ms20908 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define st first #define nd second #define MOD 1000000007 typedef pair<ll, ll> pii; typedef pair<pii, ll> piiq; const ll maxn = 2e5 + 5; ll n, m, qu, k, vis[maxn], ans[maxn]; vector<ll> v[maxn]; int main(){ cin >> n >> m >> qu >> k; memset(ans, -1, sizeof(ans)); queue<piiq> q; for (int i = 0; i < qu; i++) { ll a; cin >> a; q.push({{a, 0}, 1}); ans[a] = 0; } for (int i = 0; i < m; i++) { ll y, u; cin >> y >> u; v[y].pb(u); v[u].pb(y); } while(!q.empty()){ piiq curr = q.front(); ll index = curr.st.st, dis = curr.st.nd, day = curr.nd; q.pop(); if(vis[index]){ continue;; } vis[index] = 1; cout << index << " " << dis << " " << day << "\n"; if(dis > k){ dis = 0; day++; } if(ans[index] == -1){ ans[index] = day; } for (int i = 0; i < v[index].size(); i++) { ll next = v[index][i]; q.push({{next, dis + 1}, day}); } } for (int i = 1; i <= n; i++) { cout << ans[i] << " "; } }

Compilation message (stderr)

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