結果

問題 No.361 門松ゲーム2
ユーザー lucky3977lucky3977
提出日時 2018-10-09 17:08:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 76,468 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-02 19:00:11
合計ジャッジ時間 2,080 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 53 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 16 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 18 ms
4,380 KB
testcase_22 AC 153 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 6 ms
4,380 KB
testcase_27 AC 8 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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;
	while(s.find(res) != s.end()) res++;
	return grundy[x] = 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