結果

問題 No.8 N言っちゃダメゲーム
ユーザー rsk0315rsk0315
提出日時 2020-03-30 13:29:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 491 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 37,056 KB
最終ジャッジ日時 2023-09-02 14:29:38
合計ジャッジ時間 6,976 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
7,812 KB
testcase_01 AC 17 ms
7,808 KB
testcase_02 AC 17 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(3*10**6)

WIN = 1
LOSE = 0

p = int(input())

for _ in range(p):
    n, k = map(int, input().split())

    memo = [None for i in range(n)]
    memo[0] = LOSE
    def f(m):
        if memo[m] is not None: return memo[m]
        memo[m] = LOSE
        for i in range(1, k+1):
            if m-i < 0: break
            if f(m-i) == LOSE:
                memo[m] = WIN
                break

        return memo[m]

    print('Win' if f(n-1) == WIN else 'Lose')
0