Submission #72221

#TimeUsernameProblemLanguageResultExecution timeMemory
72221funcsrToy Train (IOI17_train)C++17
0 / 100
2062 ms30464 KiB
#include "train.h" #include <iostream> #include <vector> #include <queue> #include <set> #include <algorithm> #include <cassert> #define rep(i, n) for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() #define pb push_back #define INF (1LL<<60) #define _1 first #define _2 second using namespace std; typedef pair<int, int> P; int N, M; bool G[15][15]; int dp[14348907]; int seq[15]; int p3[16]; vector<int> who_wins(vector<int> owner, vector<int> color, vector<int> U, vector<int> V) { N = owner.size(), M = U.size(); assert(N<=15); rep(i, M) G[U[i]][V[i]] = true; p3[0] = 1; for (int i=1; i<=15; i++) p3[i] = p3[i-1]*3; for (int S=p3[N]-1; S>=0; S--) { int s = S; rep(x, N) seq[x] = s%3, s/=3; int S1 = 0; for (int x=N-1; x>=0; x--) S1 = S1*3 + (seq[x]?2:0); rep(x, N) { bool ok = false; rep(t, N) if (G[x][t]) { if (seq[t]) { if (seq[t] == 2) { ok = true; break; } } else { if (color[t]) { if ((dp[S1+2*p3[t]]>>t)&1) { ok = true; break; } } else { if ((dp[S+p3[t]]>>t)&1) { ok = true; break; } } } } if (ok) dp[S] |= 1<<x; } } vector<int> ret(N, 0); rep(i, N) { int mask = 0; if (color[i]) mask = p3[i]*2; else mask = p3[i]; ret[i] = (dp[mask]>>i)&1; } return ret; }
#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...