Submission #257940

#TimeUsernameProblemLanguageResultExecution timeMemory
257940MrRobot_28Birmingham (COCI20_birmingham)C++17
70 / 70
282 ms10616 KiB
#include<bits/stdc++.h> using namespace std; signed main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); // cout.tie(NULL); int n, m, q, k; cin >> n >> m >> q >> k; vector <int> dist(n, 1e9); queue <int> Q; for(int i = 0; i < q; i++) { int a; cin >> a; a--; dist[a] = 0; Q.push(a); } vector <vector <int> > g(n); for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; g[a].push_back(b); g[b].push_back(a); } vector <int> ans(n, 0); for(int i = 1;; i++) { while(Q.size() > 0 && dist[Q.front()] < i * (i + 1) / 2 * k) { int v = Q.front(); Q.pop(); for(int j = 0; j < g[v].size(); j++) { int to = g[v][j]; if(dist[to] > dist[v] + 1) { ans[to] = i; dist[to] = dist[v] + 1; Q.push(to); } } } if(Q.size() == 0) { break; } } for(int i = 0; i < n; i++) { cout << ans[i] << " "; } return 0; }

Compilation message (stderr)

birmingham.cpp: In function 'int main()':
birmingham.cpp:37:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 0; j < g[v].size(); j++)
                   ~~^~~~~~~~~~~~~
#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...