Submission #789936

#TimeUsernameProblemLanguageResultExecution timeMemory
789936ymmToy Train (IOI17_train)C++17
0 / 100
896 ms1532 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; int win[N]; bool vis[N]; bool dfs(int v) { vis[v] = 1; if (charg[v]) return win[v] = 1; bool ans = col[v]? 0: 1; for (int u : A[v]) { bool wu; if (vis[u]) wu = win[u] == 1; else wu = dfs(u); if (col[v]) ans |= wu; else ans &= wu; } win[v] = ans; 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) { memset(win, -1, sizeof(win)); memset(vis, 0, sizeof(vis)); ans[i] = dfs(i); } return ans; }

Compilation message (stderr)

train.cpp: In function 'bool dfs(int)':
train.cpp:20:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   20 |   return win[v] = 1;
      |          ~~~~~~~^~~
#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...