結果

問題 No.1439 Let's Compare!!!!
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-10 10:03:13
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,210 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 94,608 KB
最終ジャッジ日時 2024-05-07 03:07:18
合計ジャッジ時間 2,507 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
54,228 KB
testcase_01 AC 38 ms
53,488 KB
testcase_02 AC 41 ms
53,112 KB
testcase_03 AC 39 ms
54,044 KB
testcase_04 AC 41 ms
54,512 KB
testcase_05 AC 40 ms
54,040 KB
testcase_06 AC 42 ms
53,820 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 130 ms
77,980 KB
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 #

import heapq
class pqheap:
  def __init__(self,key=None):
    self.p = list()
    self.q = list()

  def insert(self,x):
    heapq.heappush(self.p, x)
    return

  def erase(self,x):
    heapq.heappush(self.q, x)
    return

  def minimum(self):
    while self.q and self.p[0] == self.q[0]:
      heapq.heappop(self.p)
      heapq.heappop(self.q)
    return self.p[0] if len(self.p)>0 else None
def main1(n,s,t,sary,tary,query):
  pq=pqheap()
  ret=[]
  for i in range(n):
    if sary[i]!=tary[i]:
      pq.insert(i)
  for tmp in query:
    c,x,y=tmp.split()
    x=int(x)-1
    y=int(y)
    if sary[x]!=tary[x]:
      pq.erase(x)
    if c=="S":
      sary[x]=y
    else:
      tary[x]=y
    if sary[x]!=tary[x]:
      pq.insert(x)
    idx=pq.minimum()
    if idx is None:
      ret.append("=")
    elif sary[idx]<tary[idx]:
      ret.append("<")
    elif sary[idx]>tary[idx]:
      ret.append(">")
    #print(sary,tary,idx)
  return ret

if __name__=='__main__':
  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)]
  ret1=main1(n,s,t,sary[:],tary[:],query[:])
  print(*ret1,sep="\n")
0