Submission #789947

#TimeUsernameProblemLanguageResultExecution timeMemory
789947ymmToy Train (IOI17_train)C++17
15 / 100
2080 ms1236 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 = 5050; vector<int> A[N]; int col[N]; bool charg[N]; int n, m; bool vis[N]; int height[N]; bool dfs(int v, int h, int mxc) { height[v] = h; vis[v] = 1; if (charg[v]) mxc = h; bool ans = col[v]? 0: 1; for (int u : A[v]) { bool wu; if (vis[u]) wu = height[u] <= mxc; else wu = dfs(u, h+1, mxc); if (col[v]) ans |= wu; else ans &= wu; } vis[v] = 0; return ans; } 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); } vector<int> ans(n); Loop (i,0,n) { ans[i] = dfs(i, 0, -1); } 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...