結果
| 問題 |
No.946 箱箱箱
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2019-12-13 12:23:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 710 bytes |
| コンパイル時間 | 488 ms |
| コンパイル使用メモリ | 55,084 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-27 03:31:49 |
| 合計ジャッジ時間 | 2,047 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
ソースコード
//独立なゲームに分割される不偏ゲーム -> grundy数
#include <iostream>
using namespace std;
int n;
int a[2000];
int xa[2001];
int dp[2001]; //dp[i] = 山i (= {a[i],…,a[n-1]})のgrundy数. dp[n] = 0.
int main() {
int i, j;
cin >> n;
for (i = 0; i < n; i++) cin >> a[i];
for (i = 0; i < n; i++) xa[i + 1] = xa[i] ^ a[i];
for (i = n - 1; i >= 0; i--) {
bool used[2001] = {false};
for (j = i + 1; j <= n; j++) {
//箱a[i],…,a[j-1]を開封 + 山j
int res = xa[j] ^ xa[i] ^ dp[j];
if (res < n) used[res] = true;
}
for (j = 0; ; j++) if (!used[j]) break;
dp[i] = j;
}
if (dp[0] == 0) cout << "Takanashi" << endl;
else cout << "Takahashi" << endl;
return 0;
}
startcpp