結果
問題 | No.361 門松ゲーム2 |
ユーザー |
![]() |
提出日時 | 2016-04-20 18:55:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 1,328 bytes |
コンパイル時間 | 909 ms |
コンパイル使用メモリ | 107,744 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-10 23:59:34 |
合計ジャッジ時間 | 2,035 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> //#include<cctype> #include<climits> #include<iostream> #include<string> #include<vector> #include<map> //#include<list> #include<queue> #include<deque> #include<algorithm> //#include<numeric> #include<utility> #include<complex> //#include<memory> #include<functional> #include<cassert> #include<set> #include<stack> #include<random> const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; const int MAXL = 555; int g[MAXL], D; int grundy(int L) { int& ret = g[L]; if (ret >= 0) return ret; set<int> S; for (int l1 = 1; l1 < L/3; l1++) for (int l2 = l1+1; l2+l1 < L; l2++) { int l3 = L-l1-l2; if (l3 <= l2) break; if (l3-l1 > D) continue; int g1 = grundy(l1), g2 = grundy(l2), g3 = grundy(l3); S.insert(g1^g2^g3); } ret = 0; while (1) { if (S.find(ret) == S.end()) return ret; ret++; } } int main() { cin.tie(0); ios::sync_with_stdio(false); int L; cin >> L >> D; memset(g, -1, sizeof(g)); if (grundy(L) == 0) cout << "matsu" << endl; else cout << "kado" << endl; return 0; }