結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-12 22:13:52 |
| 言語 | Python3 (3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 22 ms / 5,000 ms |
| + 882µs | |
| コード長 | 480 bytes |
| 記録 | |
| コンパイル時間 | 57 ms |
| コンパイル使用メモリ | 14,848 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2026-11-10 19:12:07 |
| 合計ジャッジ時間 | 2,075 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
# -*- 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