結果
問題 | No.8 N言っちゃダメゲーム |
ユーザー | Eguy |
提出日時 | 2022-07-16 22:26:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 4,298 ms / 5,000 ms |
コード長 | 1,357 bytes |
コンパイル時間 | 1,571 ms |
コンパイル使用メモリ | 86,676 KB |
実行使用メモリ | 235,236 KB |
最終ジャッジ日時 | 2023-09-11 08:21:11 |
合計ジャッジ時間 | 21,741 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
71,396 KB |
testcase_01 | AC | 74 ms
71,648 KB |
testcase_02 | AC | 75 ms
71,328 KB |
testcase_03 | AC | 2,312 ms
162,036 KB |
testcase_04 | AC | 3,203 ms
235,236 KB |
testcase_05 | AC | 4,298 ms
234,488 KB |
testcase_06 | AC | 1,562 ms
131,004 KB |
testcase_07 | AC | 1,724 ms
136,968 KB |
testcase_08 | AC | 2,039 ms
147,988 KB |
testcase_09 | AC | 2,134 ms
151,384 KB |
testcase_10 | AC | 2,260 ms
155,232 KB |
ソースコード
import sys, math sys.setrecursionlimit(1000000) INF = 1 << 100 #mod = 1000000007 mod = 998244353 input = lambda: sys.stdin.readline().rstrip() li = lambda: list(map(int, input().split())) class RMQ: def __init__(self, N): self.size = N self.inf = 2**31-1 self.tree = [self.inf] * (2*N+1) def query(self, l, r): # return minimum element in range [l, r) L = l + self.size R = r + self.size ans = self.inf while L < R: if R % 2: R -= 1 ans = min(ans, self.tree[R]) if L % 2: ans = min(ans, self.tree[L]) L += 1 L //= 2; R //= 2 return ans def update(self, i, v): # change A[i] to v idx = i + self.size self.tree[idx] = v while 1: idx //= 2 if idx == 0: break a, b = self.tree[idx*2+1], self.tree[idx*2] self.tree[idx] = min(a, b) def f(n, k): tree = RMQ(n+5) tree.update(n-1, 0) for i in range(n-1)[::-1]: j = min(i+k+1, n+2) x = tree.query(i+1, j) tree.update(i, x ^ 1) #print(i, x^1) if tree.query(0, 1) == 0: return 'Lose' return 'Win' P = int(input()) for _ in range(P): n, k = li() print(f(n, k))