結果
| 問題 |
No.361 門松ゲーム2
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-09-14 01:01:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 573 ms / 2,000 ms |
| コード長 | 630 bytes |
| コンパイル時間 | 526 ms |
| コンパイル使用メモリ | 63,100 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 05:14:44 |
| 合計ジャッジ時間 | 2,275 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
#include <iostream>
#include <set>
using namespace std;
int L, D;
int mem[501];
int grundy(int l) {
if (mem[l] != -1)return mem[l];
set<int> s;
for (int i = 1; i <= l; i++) {
for (int j = i + 1; j <= l - i; j++) {
for (int k = j + 1; k <= l - i - j; k++) {
if (k - i > D)break;
if (i + j + k != l) continue;
s.insert(grundy(i) ^ grundy(j) ^ grundy(k));
}
}
}
int res = 0;
while (s.count(res)) res++;
return mem[l] = res;
}
int main()
{
cin >> L >> D;
for (int i = 0; i < 501; i++) mem[i] = -1;
if (grundy(L)) {
cout << "kado" << endl;
}
else {
cout << "matsu" << endl;
}
return 0;
}
kurenai3110