結果
問題 | No.1439 Let's Compare!!!! |
ユーザー |
|
提出日時 | 2021-03-26 21:47:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 743 ms / 2,000 ms |
コード長 | 1,708 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 83,640 KB |
最終ジャッジ日時 | 2024-11-29 08:40:19 |
合計ジャッジ時間 | 8,323 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
52,224 KB |
testcase_01 | AC | 39 ms
52,480 KB |
testcase_02 | AC | 40 ms
52,224 KB |
testcase_03 | AC | 40 ms
52,224 KB |
testcase_04 | AC | 40 ms
52,864 KB |
testcase_05 | AC | 37 ms
52,224 KB |
testcase_06 | AC | 42 ms
52,096 KB |
testcase_07 | AC | 153 ms
77,440 KB |
testcase_08 | AC | 170 ms
77,972 KB |
testcase_09 | AC | 124 ms
77,184 KB |
testcase_10 | AC | 727 ms
83,380 KB |
testcase_11 | AC | 688 ms
82,876 KB |
testcase_12 | AC | 677 ms
82,432 KB |
testcase_13 | AC | 743 ms
83,572 KB |
testcase_14 | AC | 729 ms
83,640 KB |
testcase_15 | AC | 687 ms
82,596 KB |
testcase_16 | AC | 688 ms
82,792 KB |
testcase_17 | AC | 674 ms
82,792 KB |
testcase_18 | AC | 603 ms
82,560 KB |
ソースコード
class Bit: """https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree から拝借しています。""" def __init__(self, n): self.size = n self.tree = [0] * (n + 1) self.depth = n.bit_length() def __getitem__(self, item): return self.sum(item) - self.sum(item - 1) def initialize(self, A): for i, a in enumerate(A, 1): self.tree[i] = a j = (i & -i) >> 1 while j: self.tree[i] += self.tree[i - j] j >>= 1 def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, x): """ 累積和がx以上になる最小のindexと、その直前までの累積和 """ sum_ = 0 pos = 0 for i in range(self.depth, -1, -1): k = pos + (1 << i) if k <= self.size and sum_ + self.tree[k] < x: sum_ += self.tree[k] pos += 1 << i return pos + 1 N = int(input()) S = [int(x) for x in input()] T = [int(x) for x in input()] bit = Bit(N) bit.initialize((int(s != t) for s, t in zip(S, T))) Q = int(input()) for _ in range(Q): c, x, y = input().split() x = int(x) - 1 y = int(y) if c == 'S': S[x] = y else: # c=='T' T[x] = y bit.add(x + 1, int(S[x] != T[x]) - bit[x + 1]) idx = bit.lower_bound(1) - 1 if idx == N: print('=') elif S[idx] > T[idx]: print('>') elif S[idx] < T[idx]: print('<')