結果
| 問題 |
No.361 門松ゲーム2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-10-09 16:42:41 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 703 bytes |
| コンパイル時間 | 709 ms |
| コンパイル使用メモリ | 75,040 KB |
| 実行使用メモリ | 13,648 KB |
| 最終ジャッジ日時 | 2024-10-12 16:34:54 |
| 合計ジャッジ時間 | 9,390 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 1 TLE * 2 -- * 13 |
ソースコード
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int grundy[510];
void init_grundy(){
for(int i = 0; i < 6; i++){
grundy[i] = 0;
}
for(int i = 6; i < 510; i++){
grundy[i] = -1;
}
}
int calc(int x, int d){
if(grundy[x] >= 0) return grundy[x];
set<int> s;
for(int i = 1; i < x / 3; i++){
for(int j = i + 1; j < (x - i + 1) / 2; j++){
int k = x - i - j;
if(k - i <= d){
s.insert(calc(i, d) ^ calc(j, d) ^ calc(k, d));
}
}
}
int res = 0;
if(s.count(res)) res++;
return res;
}
int main(){
int l, d, win = 0;
cin >> l >> d;
init_grundy();
win = calc(l, d);
if(win){
cout << "kado" << endl;
}else{
cout << "matsu" << endl;
}
return 0;
}