結果

問題 No.361 門松ゲーム2
ユーザー lucky3977lucky3977
提出日時 2018-10-09 16:42:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 75,188 KB
実行使用メモリ 13,764 KB
最終ジャッジ日時 2024-04-20 19:09:01
合計ジャッジ時間 8,980 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,764 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,816 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 40 ms
6,940 KB
testcase_09 AC 1,922 ms
6,944 KB
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 137 ms
6,940 KB
testcase_12 AC 1,458 ms
6,944 KB
testcase_13 WA -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
	if(s.count(res)) res++;
	return 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;
}
0