結果
問題 |
No.361 門松ゲーム2
|
ユーザー |
![]() |
提出日時 | 2016-09-13 22:17:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,377 bytes |
コンパイル時間 | 1,862 ms |
コンパイル使用メモリ | 176,692 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-17 05:06:16 |
合計ジャッジ時間 | 2,866 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; namespace { typedef double real; typedef long long ll; template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) { if (vs.empty()) return os << "[]"; auto i = vs.begin(); os << "[" << *i; for (++i; i != vs.end(); ++i) os << " " << *i; return os << "]"; } template<class T> istream& operator>>(istream& is, vector<T>& vs) { for (auto it = vs.begin(); it != vs.end(); it++) is >> *it; return is; } int L, D; void input() { cin >> L >> D; } map<pair<int, int>, int> cache; bool dfs(int x, int w) { auto key = make_pair(x, w); if (cache.count(key)) return cache[key]; for (int a = 1; a <= x; a++) { for (int b = a; a + b <= x; b++) { int c = x - a - b; if (c < b) continue; if (c - a > D) continue; if (a == b || b == c || c == a) continue; //cout << "abc: " << a << " " << b << " " << c << endl; if ((dfs(a, !w) ^ dfs(b, !w) ^ dfs(c, !w)) == 0) return cache[key] = true; } } return cache[key] = false; } void solve() { cout << (dfs(L, 0) ? "kado" : "matsu") << endl; } } int main() { input(); solve(); return 0; }