結果
問題 | No.22 括弧の対応 |
ユーザー |
|
提出日時 | 2022-06-24 12:31:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 54 ms / 5,000 ms |
コード長 | 427 bytes |
コンパイル時間 | 184 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 61,952 KB |
最終ジャッジ日時 | 2024-11-08 05:31:51 |
合計ジャッジ時間 | 2,085 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
n,k=map(int,input().split()) k-=1 s=input() stack=[] ans=[] for i in range(n): if stack: last,ind=stack[-1][0],stack[-1][1] if last=='(' and s[i]==')': stack.pop() ans.append((ind,i)) else: stack.append((s[i],i)) else: stack.append((s[i],i)) for x,y in ans: if x==k: print(y+1) break elif y==k: print(x+1) break