結果

問題 No.8 N言っちゃダメゲーム
ユーザー koyumeishikoyumeishi
提出日時 2015-01-08 01:56:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 917 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 73,464 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 22:20:15
合計ジャッジ時間 1,273 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cmath>
#include "assert.h"
#include <ctime>
#include <stdexcept>

using namespace std;

int N,K;
vector<int> memo;

int grundy(int x){
	
	if(memo.at(x)>=0){
		return memo.at(x);
	}
	//cerr << "grundy " << x << endl;

	int ret = 0;
	for(int i=1; i<=K; i++){
		if(x+i >= N) break;
		if(grundy(x+i) == 0){
			ret = 1;
			break;
		}
	}
	
	
	memo.at(x) = ret;
	return ret;
}

void solve(){
	cin >> N >> K;
	/*
	memo = vector<int>(120000+1, -1);
	int ans = grundy(0);
	for(int i=0; i<=N; i++){
		cerr << i << " " << memo[i] << endl;
	}
	
	cout << (ans!=0? "Win":"Lose") << endl;
	*/

	bool ans = (N-1)%(K+1) == 0 ? false : true;
	cout << (ans? "Win":"Lose") << endl;
}

int main(){
	int T;
	cin >> T;
	for(int i=0; i<T; i++){
		solve();
	}
	return 0;
}
0