結果
問題 | No.1506 Unbalanced Pocky Game |
ユーザー |
|
提出日時 | 2021-05-14 22:42:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 948 bytes |
コンパイル時間 | 647 ms |
コンパイル使用メモリ | 72,880 KB |
実行使用メモリ | 22,148 KB |
最終ジャッジ日時 | 2024-10-02 02:50:01 |
合計ジャッジ時間 | 4,150 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 WA * 29 |
ソースコード
#include <iostream> #include <vector> using namespace std; int dfs(int now, int t, vector<vector<int>>&dp, vector<int>&A, bool turn){ if(dp[t][now] != -1) return dp[t][now]; if(t == 0) return dfs(now - 1, A[now - 1], dp, A, !turn); if(turn){ bool f = false; for(int j = 0; j < t; j++){ f |= dfs(now, j, dp, A, !turn); } return dp[t][now] = f; } else{ bool f = true; for(int j = 0; j < t; j++){ f &= dfs(now, j, dp, A, !turn); } return dp[t][now] = f; } } int main(){ int N; cin >> N; vector<int> A(N); int sum = 0; for(int i = 0; i < N; i++) { cin >> A[i]; if(A[i] > 1) A[i] = 2; } vector<vector<int>> dp(3, vector<int>(N, -1)); dp[0][0] = true; dp[1][0] = false; bool res = dfs(N - 1, A[N - 1], dp, A, true); if(res) cout << "Alice" << endl; else cout << "Bob" << endl; }