結果
問題 | No.361 門松ゲーム2 |
ユーザー |
![]() |
提出日時 | 2016-04-17 23:50:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 246 ms / 2,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 529 ms |
コンパイル使用メモリ | 71,888 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 11:05:53 |
合計ジャッジ時間 | 1,852 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <iostream>#include <algorithm>#include <unordered_set>using namespace std;int memo[501];int L, D;int grundy(int x){int& res=memo[x];if (~res) return res;unordered_set<int> s;for(int i=1; i<x; ++i) {for(int j=i+1; j<x; ++j) {int k=x-i-j;if (k<=0 or i==k or j==k) continue;if (max({i, j, k})-min({i, j, k})>D) continue;s.insert(grundy(i)^grundy(j)^grundy(k));}}res=0;while (s.count(res)) ++res;return res;}int main(){fill(memo, memo+501, -1);cin>>L>>D;cout<<(grundy(L) ? "kado" : "matsu")<<endl;}