結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-12 22:13:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 5,000 ms |
| コード長 | 480 bytes |
| コンパイル時間 | 85 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-07-20 07:25:13 |
| 合計ジャッジ時間 | 1,453 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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