Submission #790026

#TimeUsernameProblemLanguageResultExecution timeMemory
790026ymmToy Train (IOI17_train)C++17
0 / 100
992 ms1228 KiB
#include "train.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (long long x = (l); x < (r); ++x) typedef long long ll; typedef std::pair<ll,ll> pll; using namespace std; const int N = 5032; vector<int> A[N]; bool vis[N]; bool reach_self[N]; bool col[N], charg[N]; int n, m; bool dfs(int v, int rt) { vis[v] = 1; for (int u : A[v]) { if (charg[u]) continue; if (u == rt) return 1; if (vis[u]) continue; if (dfs(u, rt)) return 1; } return 0; } void dfs2(int v) { vis[v] = 1; for (int u : A[v]) { if (!vis[u]) dfs2(u); } } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> V, std::vector<int> U) { n = a.size(); m = V.size(); Loop (i,0,n) { col[i] = a[i]; charg[i] = r[i]; } Loop (i,0,m) { int v = V[i], u = U[i]; A[v].push_back(u); } Loop (i,0,n) { if (charg[i]) continue; memset(vis, 0, sizeof(vis)); reach_self[i] = dfs(i, i); } vector<int> ans(n); Loop (i,0,n) { memset(vis, 0, sizeof(vis)); dfs2(i); Loop (i,0,n) ans[i] |= reach_self[i]; ans[i] = !ans[i]; } return ans; }
#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...