結果
問題 |
No.1506 Unbalanced Pocky Game
|
ユーザー |
|
提出日時 | 2021-05-14 22:53:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 909 bytes |
コンパイル時間 | 682 ms |
コンパイル使用メモリ | 73,468 KB |
実行使用メモリ | 22,024 KB |
最終ジャッジ日時 | 2024-10-02 03:20:15 |
合計ジャッジ時間 | 4,235 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 WA * 24 |
ソースコード
#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); 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; bool res = dfs(N - 1, A[N - 1], dp, A, true); if(res) cout << "Alice" << endl; else cout << "Bob" << endl; }