結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-01-27 16:46:54 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 5,000 ms |
| コード長 | 436 bytes |
| コンパイル時間 | 196 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-07-20 07:47:12 |
| 合計ジャッジ時間 | 1,343 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,K = map(int,readline().split())
S = read().rstrip().decode()
stack = [(-1,'$')]
pair = dict()
for i,s in enumerate(S,1):
if s == ')' and stack[-1][1] == '(':
j = stack[-1][0]
pair[i] = j
pair[j] = i
stack.pop()
else:
stack.append((i,s))
answer = pair[K]
print(answer)
maspy