結果

問題 No.1439 Let's Compare!!!!
ユーザー googol_S0googol_S0
提出日時 2021-03-26 21:59:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,017 ms / 2,000 ms
コード長 1,287 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 86,788 KB
実行使用メモリ 140,512 KB
最終ジャッジ日時 2023-08-19 15:19:51
合計ジャッジ時間 11,766 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
71,640 KB
testcase_01 AC 82 ms
71,780 KB
testcase_02 AC 82 ms
71,744 KB
testcase_03 AC 84 ms
71,396 KB
testcase_04 AC 86 ms
71,648 KB
testcase_05 AC 84 ms
71,696 KB
testcase_06 AC 81 ms
71,520 KB
testcase_07 AC 184 ms
80,608 KB
testcase_08 AC 205 ms
80,012 KB
testcase_09 AC 168 ms
79,356 KB
testcase_10 AC 988 ms
137,308 KB
testcase_11 AC 1,017 ms
137,180 KB
testcase_12 AC 955 ms
134,812 KB
testcase_13 AC 984 ms
140,304 KB
testcase_14 AC 978 ms
140,512 KB
testcase_15 AC 958 ms
138,220 KB
testcase_16 AC 875 ms
138,240 KB
testcase_17 AC 917 ms
138,332 KB
testcase_18 AC 827 ms
138,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import *
def init(N,node,A,unit,func):
  n=1
  while n<N:
    n<<=1
  for i in range(n*2-1):
    if len(node)<=i:
      node.append(deepcopy(unit))
    else:
      node[i]=deepcopy(unit)
  for i in range(len(A)):
    node[n-1+i]=deepcopy(A[i])
  for i in range(n-2,-1,-1):
    node[i]=func(node[(i<<1)+1],node[(i<<1)+2])
  node.append(func)
  node.append(unit)
  node.append(n)

def upd(node,x,a):
  y=node[-1]+x
  node[y-1]=a
  while y>1:
    y=y>>1
    node[y-1]=node[-3](node[(y<<1)-1],node[y<<1])

def query(node,l,r):
  x,y=l,r
  z=node[-1]-1
  rr=deepcopy(node[-2])
  rl=deepcopy(node[-2])
  while True:
    if x==y:
      return node[-3](rl,rr)
    if x&1:
      rl=node[-3](rl,node[x+z])
      x+=1
    if y&1:
      rr=node[-3](node[y+z-1],rr)
    if z==0:
      return node[-3](rl,rr)
    x>>=1
    y>>=1
    z>>=1

N=int(input())
S=list(input())
T=list(input())
for i in range(N):
  S[i]=int(S[i])
  T[i]=int(T[i])
seg=[]
def f(x,y):
  if x==0:
    return y
  else:
    return x

init(N,seg,[S[i]-T[i] for i in range(N)],0,f)
Q=int(input())
for i in range(Q):
  c,x,y=input().split()
  x,y=int(x)-1,int(y)
  if c=='S':
    S[x]=y
  else:
    T[x]=y
  upd(seg,x,S[x]-T[x])
  A=query(seg,0,N)
  if A==0:
    print('=')
  elif A<0:
    print('<')
  else:
    print('>')
0