結果

問題 No.361 門松ゲーム2
ユーザー pekempey
提出日時 2016-04-17 22:48:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 1,501 ms
コンパイル使用メモリ 165,228 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 10:41:47
合計ジャッジ時間 2,293 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int L, D;
int dp[1000];

int g(int L) {
	if (dp[L] != -1) return dp[L];

	set<int> st;
	for (int i = 1; i < L; i++) {
		for (int j = i + 1; i + j < L; j++) {
			int k = L - i - j;
			if (k <= j) continue;
			if (k - i <= D) {
				st.insert(g(i) ^ g(j) ^ g(k));
			}
		}
	}

	int result = 0;
	while (st.count(result)) result++;
	return dp[L] = result;
}

int main() {
	cin >> L >> D;
	memset(dp, -1, sizeof(dp));

	if (g(L) != 0) {
		cout << "kado" << endl;
	} else {
		cout << "matsu" << endl;
	}
}
0