結果
問題 |
No.361 門松ゲーム2
|
ユーザー |
|
提出日時 | 2018-10-09 17:08:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 154 ms / 2,000 ms |
コード長 | 728 bytes |
コンパイル時間 | 816 ms |
コンパイル使用メモリ | 74,880 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 16:35:35 |
合計ジャッジ時間 | 2,030 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#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; while(s.find(res) != s.end()) res++; return grundy[x] = 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; }