結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-12 22:13:52 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 5,000 ms |
| + 222µs | |
| コード長 | 480 bytes |
| 記録 | |
| コンパイル時間 | 291 ms |
| コンパイル使用メモリ | 21,284 KB |
| 実行使用メモリ | 15,868 KB |
| 最終ジャッジ日時 | 2026-08-19 17:50:37 |
| 合計ジャッジ時間 | 3,696 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
# -*- coding: utf-8 -*-
from collections import deque
class paren:
def __init__(self, char, id):
self.char = char
self.id = id
N, K = map(int, input().split())
S = input()
parentheses = deque()
for (c,i) in zip(S, range(1, len(S)+1)):
p = paren(c,i)
if len(parentheses)==0 or c=='(':
parentheses.append(p)
else:
q = parentheses.pop()
if p.id==K or q.id==K:
print(q.id if p.id==K else p.id)
break