Submission #845205

#TimeUsernameProblemLanguageResultExecution timeMemory
845205vjudge1Birmingham (COCI20_birmingham)C++17
0 / 70
110 ms7876 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; constexpr static int MXN = 1e5; int n, m, k, q; bitset<MXN> visited; vector<int> g[MXN]; vector<int> v; int res[MXN]; void dfs(int node, int s, int c) { visited[node] = true; if (c != s*k) res[node] = s; if (c == 0) { v.pb(node); return; } for (int cc : g[node]) { if (!visited[cc]) dfs(cc, s, c-1); } } int main() { cin >> n >> m >> q >> k; for (int i = 0; i < q; i++) { int val; cin >> val; v.pb(val-1); } for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--,b--; g[a].pb(b); g[b].pb(a); } int j = 1; while (v.size()) { vector<int> t = v; v.clear(); for (int i : t) visited[i] = true; for (int i : t) dfs(i, j, j*k); j++; } for (int i = 0; i < n; i++) cout << res[i] << " "; cout << "\n"; }
#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...