結果

問題 No.8 N言っちゃダメゲーム
ユーザー prog470prog470
提出日時 2016-09-24 10:00:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,220 bytes
コンパイル時間 1,188 ms
コンパイル使用メモリ 68,820 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 23:12:35
合計ジャッジ時間 1,219 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int P, N[120005], K[120005], dp[120005];

int f(int n, int I) {
	if (dp[n] != -1) {
		return dp[n];
	}
	if (n == N[I] -1) {
		return dp[I] = 1;
	}
	if (n >= N[I]) {
		return dp[n] = 0;
	}
	bool flag = false;
	for (int i = 1; i <= K[I]; i++) {
		if (f(n + i, I) == 1) flag = true;
	}
	if (flag) return dp[n] = 0;	//相手の宣言できる数の中に、一つでも「○」があるなら負け
	else return dp[n] = 1;
}

int main() {
	cin >> P;
	for (int i = 0; i < P; i++) {
		cin >> N[i] >> K[i];
	}

	for (int i = 0; i < P; i++) {
		if ((N[i] - 1) % (K[i] + 1) == 0) cout << "Lose" << endl;
		else cout << "Win" << endl;
	}

	/*
	for (int i = 0; i < P; i++) {
		fill(dp, dp + 120005, -1);
		bool flag = false;
		for (int j = 1; j <= K[i]; j++) {	//初手で一つでも価値ルートがあるならば、先行(自分)の勝ち
			if (f(j, i) == 1) {
				flag = true;
				break;
			}
		}
		if (flag) cout << "Win" << endl;
		else cout << "Lose" << endl;
	}
	*/

	return 0;
}
0