結果

問題 No.2398 ヒドラ崩し
ユーザー gew1fw
提出日時 2025-06-12 14:30:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 61,312 KB
最終ジャッジ日時 2025-06-12 14:30:47
合計ジャッジ時間 2,474 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

H = input().strip()

max_depth = 0
count = 0
current_depth = 0
i = 0
n = len(H)

while i < n:
    if H[i] == '(' and i + 1 < n and H[i+1] == ')':
        depth = current_depth
        if depth > max_depth:
            max_depth = depth
            count = 1
        elif depth == max_depth:
            count += 1
        i += 2
    else:
        if H[i] == '(':
            current_depth += 1
        else:
            current_depth -= 1
        i += 1

if count % 2 == 1:
    print(0)
else:
    print(1)
0