結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2025-03-23 11:06:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 46 ms / 5,000 ms |
コード長 | 400 bytes |
コンパイル時間 | 461 ms |
コンパイル使用メモリ | 82,312 KB |
実行使用メモリ | 61,092 KB |
最終ジャッジ日時 | 2025-03-23 11:06:16 |
合計ジャッジ時間 | 2,497 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
import syssys.set_int_max_str_digits(0)N, K = map(int, input().split())S = input()stack = []for i, s in enumerate(S, 1):if stack and stack[-1][0] == '(' and s == ')':# stack[-1][1] と i がペアx, y = stack[-1][1], iif x == K:exit(print(y))if y == K:exit(print(x))stack.pop()else:stack.append((s, i))