Submission #1064165

#TimeUsernameProblemLanguageResultExecution timeMemory
1064165IgnutToy Train (IOI17_train)C++17
22 / 100
790 ms1628 KiB
// Ignut #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5555; int n, m; vector<int> a, r; vector<int> g[N]; bool ans = false; int used[N]; bool good[N]; void dfs(int v) { used[v] = true; ans |= good[v]; if (ans) return; for (int to : g[v]) if (!used[to]) dfs(to); } void dfs1(int v, int st) { if (good[st]) return; used[v] = true; for (int to : g[v]) { if (to == st) { good[st] = true; return; } if (!used[to]) dfs1(to, st); } } void dfs2(int v, int st) { if (good[st]) return; used[v] = true; for (int to : g[v]) { if (r[to] == 1) continue; if (to == st) { good[st] = true; return; } if (!used[to]) dfs2(to, st); } } vector<int> who_wins(vector<int> A, vector<int> R, vector<int> u, vector<int> v) { n = A.size(), m = u.size(); a = A, r = R; for (int i = 0; i < m; i ++) { g[u[i]].push_back(v[i]); } if (a[0] == 1) { // all Arez for (int i = 0; i < n; i ++) { if (r[i] == 0) continue; for (int j = 0; j < n; j ++) used[j] = false; dfs1(i, i); } } else { // all Borz for (int i = 0; i < n; i ++) { if (r[i] == 1) continue; for (int j = 0; j < n; j ++) used[j] = false; dfs2(i, i); } } vector<int> res; for (int s = 0; s < n; s ++) { ans = false; for (int i = 0; i < n; i ++) used[i] = 0; dfs(s); res.push_back(ans ^ (a[0] == 0)); } return res; }
#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...