結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2017-09-19 00:32:18 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 41 ms / 5,000 ms |
コード長 | 759 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-07-20 07:25:46 |
合計ジャッジ時間 | 1,527 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
try: import mydebug def dprint(*objects, sep='', end='\n'): print(*objects) except: def dprint(*objects, sep='', end='\n'): pass n, k = [int(x) for x in input().split()] s = input().rstrip() stc = [] pairs = [] dprint(s) state = "" dprint("len(s)",len(s)) for i in range(len(s)): dprint("-----", i+1, s[i]) if s[i] == "(": dprint("append", i+1) stc.append(i+1) state += "(" dprint(state) else: state = state[:-1] dprint(state) dprint("pop", stc[-1]) pairs.append((i+1, stc[-1])) stc.pop() def other(t, n): if t[0] == n: return t[1] else: return t[0] for p in pairs: if k in p: dprint(p) print(other(p, k))