Submission #219323

#TimeUsernameProblemLanguageResultExecution timeMemory
219323VimmerBirmingham (COCI20_birmingham)C++14
70 / 70
112 ms8152 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define F first #define S second #define sz(x) ll(x.size()) #define pb push_back #define N 100005 #define M ll(998244353) using namespace std; //using namespace __gnu_pbds; typedef long double ld; typedef long long ll; typedef short int si; //typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> oredered_set; vector <int> g[N]; int main() { ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, q, k; cin >> n >> m >> q >> k; vector <int> gr(q); for (int i = 0; i < q; i++) cin >> gr[i]; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; g[a].pb(b); g[b].pb(a); } int ans[n + 1], kol = q; for (int i = 1; i <= n; i++) ans[i] = -1; for (auto it : gr) ans[it] = 0; int day = 1; while (kol < n) { vector <int> vr; vr.clear(); for (int i = 0; i < day * k && kol < n; i++) { for (auto it : gr) { if (kol == n) break; for (auto itr : g[it]) { if (kol == n) break; if (ans[itr] != -1) continue; ans[itr] = day; kol++; vr.pb(itr); } } gr = vr; vr.clear(); } day++; } for (int i = 1; i <= n; i++) cout << ans[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...