結果

問題 No.2398 ヒドラ崩し
ユーザー testestesttestestest
提出日時 2023-06-28 09:28:01
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 983 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 315,108 KB
最終ジャッジ日時 2023-09-18 13:28:13
合計ジャッジ時間 7,884 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,292 KB
testcase_01 AC 70 ms
71,224 KB
testcase_02 AC 71 ms
71,060 KB
testcase_03 AC 71 ms
70,932 KB
testcase_04 AC 72 ms
70,908 KB
testcase_05 AC 73 ms
71,228 KB
testcase_06 AC 72 ms
71,284 KB
testcase_07 AC 71 ms
71,004 KB
testcase_08 AC 70 ms
70,924 KB
testcase_09 AC 70 ms
70,916 KB
testcase_10 AC 72 ms
71,184 KB
testcase_11 AC 73 ms
71,276 KB
testcase_12 AC 71 ms
70,936 KB
testcase_13 AC 72 ms
71,272 KB
testcase_14 AC 70 ms
70,936 KB
testcase_15 AC 72 ms
71,024 KB
testcase_16 AC 74 ms
70,900 KB
testcase_17 AC 73 ms
71,080 KB
testcase_18 AC 74 ms
70,896 KB
testcase_19 AC 73 ms
71,036 KB
testcase_20 AC 75 ms
70,920 KB
testcase_21 AC 75 ms
70,896 KB
testcase_22 AC 72 ms
71,188 KB
testcase_23 AC 74 ms
71,188 KB
testcase_24 AC 84 ms
75,496 KB
testcase_25 AC 163 ms
84,868 KB
testcase_26 AC 191 ms
109,632 KB
testcase_27 AC 190 ms
121,412 KB
testcase_28 AC 234 ms
120,148 KB
testcase_29 TLE -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def decompose_all(S,l=0):
  # (str,int)->hydra,int
  # 次に見るところを返す
  ret=[]
  while l<len(S) and S[l]=="(":
    h,l=decompose_all(S,l+1)
    ret.append(h)
  return ret,l+1

def get_righttop(arr):
  # hydra -> hydra
  logright=arr[-1]
  if logright==[]: return [[]]
  logrightlogright=logright[-1]
  if logrightlogright==[]: return arr[-1:]
  return get_righttop(logright)

def process(arr):
  # hydra -> hydra
  logright=arr.pop()
  if logright==[]: return arr
  logrightlogright=logright[-1]
  if logrightlogright==[]:
    logright.pop()
    arr.append(logright)
    return arr
  arr.append(process(logright))
  return arr

def g(arr):
  # hydra -> int
  if arr==[]: return 0
  righttop=get_righttop(arr)
  if righttop==[[]]: return 1 if g(process(arr))==0 else 0
  if righttop==[[[]]]: return 3 if g(process(arr))==2 else 2
  return 1 if g(process(righttop))==0 else 0

import sys
sys.setrecursionlimit(10**9)

S=input()
print(0 if g(decompose_all(S)[0]) else 1)
0