結果

問題 No.8 N言っちゃダメゲーム
ユーザー nanaenanae
提出日時 2017-04-17 22:02:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 662 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 39,512 KB
最終ジャッジ日時 2023-09-26 10:57:34
合計ジャッジ時間 6,678 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)

def solve():
    def memo_rec(m):
        if m == 0:
            return True
        if dp[m] is not None:
            return dp[m]

        for i in range(1, k + 1):
            if m - i < 0:
                break
            if not memo_rec(m - i):
                dp[m] = True
                return True

        dp[m] = False
        return False

    P = int(input())

    for game in range(P):
        n, k = map(int, input().split())

        dp = [None] * (n + 1)
        dp[0] = True

        ans = memo_rec(n)

        ans = 'Win' if ans else 'Lose'

        print(ans)

if __name__ == '__main__':
    solve()
0