結果
問題 | No.361 門松ゲーム2 |
ユーザー | Nikkuniku029 |
提出日時 | 2023-11-23 17:18:56 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,678 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 12,032 KB |
実行使用メモリ | 20,352 KB |
最終ジャッジ日時 | 2023-11-23 17:19:02 |
合計ジャッジ時間 | 5,619 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
20,352 KB |
testcase_01 | AC | 31 ms
10,240 KB |
testcase_02 | AC | 30 ms
10,240 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 31 ms
10,240 KB |
testcase_06 | AC | 30 ms
10,240 KB |
testcase_07 | AC | 31 ms
10,240 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 52 ms
10,240 KB |
testcase_11 | AC | 32 ms
10,240 KB |
testcase_12 | AC | 58 ms
10,240 KB |
testcase_13 | WA | - |
testcase_14 | AC | 373 ms
10,240 KB |
testcase_15 | AC | 320 ms
10,240 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
ソースコード
def segfunc(x, y): return min(x, y) class SegTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num for i in range(n): self.tree[self.num + i] = init_val[i] for i in range(self.num - 1, 0, -1): self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def add(self, k, x): k += self.num self.tree[k] += x while k > 1: self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) k >>= 1 def update(self, k, x): k += self.num self.tree[k] = x while k > 1: self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) k >>= 1 def query(self, l, r): res = self.ide_ele l += self.num r += self.num while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: res = self.segfunc(res, self.tree[r - 1]) l >>= 1 r >>= 1 return res L, D = map(int, input().split()) dp = [0] * (L + 1) for x in range(1, L + 1): Seg = SegTree([i for i in range(L + 1)], segfunc, 1 << 60) for a in range(1, x - D + 1): for b in range(a + 1, x - D + 1): c = x - a - b if b < c and c - a <= D: xor = dp[a] ^ dp[b] ^ dp[c] Seg.update(xor, 1 << 60) dp[x] = Seg.query(0, L + 1) ans = "kado" if dp[L] else "matsu" print(ans)