結果

問題 No.8 N言っちゃダメゲーム
ユーザー hotpepsihotpepsi
提出日時 2015-02-23 00:29:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 651 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 64,688 KB
実行使用メモリ 11,600 KB
最終ジャッジ日時 2023-09-06 03:03:11
合計ジャッジ時間 7,443 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <cstring>

using namespace std;

int memo[120001];
int N, K;

static int solve(int x) {
	if (x >= (N - 1)) {
		return 0;
	}
	int &r = memo[x];
	if (r < 0) {
		r = 0;
		for (int a = 1; a <= K; ++a) {
			if (!solve(x + a)) {
				r = 1;
				break;
			}
		}
	}
	return r;
}

int main(int argc, char *argv[])
{
	string s;
	getline(cin, s);
	int T = atoi(s.c_str());
	for (int i = 0; i < T; ++i) {
		getline(cin, s);
		stringstream ss(s);
		ss >> N >> K;
		memset(memo, -1, sizeof(memo));
		string ans = solve(0) ? "Win" : "Lose";
		cout << ans << endl;
	}
	return 0;
}
0