結果

問題 No.1439 Let's Compare!!!!
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-10 09:24:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,195 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,660 KB
実行使用メモリ 92,136 KB
最終ジャッジ日時 2024-05-07 02:25:34
合計ジャッジ時間 2,857 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,852 KB
testcase_01 AC 40 ms
52,740 KB
testcase_02 AC 39 ms
52,708 KB
testcase_03 WA -
testcase_04 AC 45 ms
58,836 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 0-indexed binary indexed tree
class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0]*(n+1)
    self.el = [0]*(n+1)
  # sum of [0,i) sum(a[:i])
  def sum(self, i):
    if i==0:return 0
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    i+=1
    self.el[i] += x
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  # sum of [l,r)   sum(a[l:r])
  def sumlr(self, i, j):
    return self.sum(j) - self.sum(i)
  # a[i]
  def get(self,i):
    i+=1
    return self.el[i]
n=int(input())
s=input()
sary=list(map(int,list(s)))
s=int(s)
t=input()
tary=list(map(int,list(t)))
t=int(t)
q=int(input())
query=[input() for _ in range(q)]
dary=[x-y for x,y in zip(sary,tary)]
bit=BIT(n)
for i,x in enumerate(dary):
  bit.add(i,x)
for tmp in query:
  c,x,y=tmp.split()
  x=int(x)
  y=int(y)
  pre=dary[x-1]
  if c=="S":
    sary[x-1]=y
  else:
    tary[x-1]=y
  dary[x-1]=sary[x-1]-tary[x-1]
  bit.add(x-1,-pre+dary[x-1])
  l,r=0,n+1
  while r-l>1:
    x=(r+l)//2
    if bit.sum(x)!=0:
      l,r=l,x
    else:
      l,r=x,r
  tmp=bit.sum(l+1)
  if tmp==0:
    print("=")
  elif tmp<0:
    print("<")
  else:
    print(">")

0