結果
問題 | No.1439 Let's Compare!!!! |
ユーザー | marroncastle |
提出日時 | 2021-03-26 22:21:08 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,737 bytes |
コンパイル時間 | 297 ms |
コンパイル使用メモリ | 82,004 KB |
実行使用メモリ | 137,568 KB |
最終ジャッジ日時 | 2024-05-06 16:02:39 |
合計ジャッジ時間 | 5,669 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,608 KB |
testcase_01 | AC | 37 ms
52,736 KB |
testcase_02 | AC | 39 ms
52,480 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 231 ms
116,864 KB |
ソースコード
class SegmentTree(): def __init__(self, n, oper, e): self.n = n self.oper = oper self.e = e self.log = (n - 1).bit_length() self.size = 1 << self.log self.data = [e] * (2 * self.size) def update(self, k): self.data[k] = self.oper(self.data[2 * k], self.data[2 * k + 1]) def build(self, arr): #assert len(arr) <= self.n for i in range(self.n): self.data[self.size + i] = arr[i] for i in range(self.size-1,0,-1): self.update(i) def set(self, p, x): #assert 0 <= p < self.n p += self.size self.data[p] = x for i in range(self.log): p >>= 1 self.update(p) def get(self, p): #assert 0 <= p < self.n return self.data[p + self.size] def prod(self, l, r): #assert 0 <= l <= r <= self.n sml = smr = self.e l += self.size r += self.size while l < r: if l & 1: sml = self.oper(sml, self.data[l]) l += 1 if r & 1: r -= 1 smr = self.oper(self.data[r], smr) l >>= 1 r >>= 1 return self.oper(sml, smr) def all_prod(self): return self.data[1] def max_right(self, l, f): #assert 0 <= l <= self.n #assert f(self.) if l == self.n: return self.n l += self.size sm = self.e while True: while l % 2 == 0: l >>= 1 if not f(self.oper(sm, self.data[l])): while l < self.size: l = 2 * l if f(self.oper(sm, self.data[l])): sm = self.oper(sm, self.data[l]) l += 1 return l - self.size sm = self.oper(sm, self.data[l]) l += 1 if (l & -l) == l: break return self.n def min_left(self, r, f): #assert 0 <= r <= self.n #assert f(self.) if r == 0: return 0 r += self.size sm = self.e while True: r -= 1 while r > 1 and (r % 2): r >>= 1 if not f(self.oper(self.data[r], sm)): while r < self.size: r = 2 * r + 1 if f(self.oper(self.data[r], sm)): sm = self.oper(self.data[r], sm) r -= 1 return r + 1 - self.size sm = self.oper(self.data[r], sm) if (r & -r) == r: break return 0 import sys input = sys.stdin.readline def op(x, y): return x*10+y e = 0 N = int(input()) S = list(map(int,list(input()[:-1]))) T = list(map(int,list(input()[:-1]))) Q = int(input()) st1 = SegmentTree(N,op,e) st1.build(S) st2 = SegmentTree(N,op,e) st2.build(T) ans = [] for i in range(Q): c,x,y = input().split() x = int(x)-1; y = int(y) if c=='S': st1.set(x,y) else: st2.set(x,y) s = st1.all_prod(); t = st2.all_prod() if s < t: ans.append('<') elif s==t: ans.append('=') else: ans.append('>') print(*ans, sep='\n')