結果

問題 No.8 N言っちゃダメゲーム
ユーザー koyumeishikoyumeishi
提出日時 2015-01-08 00:48:04
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 697 bytes
コンパイル時間 1,025 ms
コンパイル使用メモリ 79,908 KB
実行使用メモリ 24,364 KB
最終ジャッジ日時 2023-09-03 22:19:41
合計ジャッジ時間 7,625 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 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 <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cmath>

using namespace std;

int grundy(vector<int> &memo, int x, const int &N, const int &K){
	if(memo[x] >= 0) return memo[x];

	set<int> s;
	for(int i=1; i<=K; i++){
		if(x+i >= N) break;
		s.insert( grundy(memo, x+i, N, K) );
	}
	int ret = 0;
	while( s.count(ret) != 0 ) ret++;
	memo[x] = ret;
	return ret;
}

void solve(){
	int N,K;
	cin >> N >> K;
	vector<int> memo(N+1, -1);
	cout << (grundy(memo,0,N,K) != 0? "Win":"Lose") << endl;
}

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