結果

問題 No.22 括弧の対応
ユーザー SaimonSaimon
提出日時 2023-11-13 19:01:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,007 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2023-11-13 19:01:29
合計ジャッジ時間 1,796 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,112 KB
testcase_01 AC 27 ms
10,112 KB
testcase_02 AC 28 ms
10,112 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 27 ms
10,112 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():

  N,S=(int(x) for x in input().split())

  l = input()

  list = []

  for i in l:
      list.append(i)

  for i in range(N):
        
        i = 0

        if list[i] == "(":

            for j in range(N-(i+1)):

                if list[i+j+1] == "(" or list[i+j+1] == "0":

                   continue   

                elif list[i+j+1] == ")":

                    list[i+j+1] = "0"



                    for k in range(i+j+1,-1,-1):

                        if list[k] == "(":
                             
                            m = k 
                            list[k] = "0"
                            break
    
                    if m+1 == S:
                        print(i+j+2)
                        break
                        
                    elif i+j+2 == S:
                        print(m+1)
                        break
                
                    else:
                        break
                        
if __name__ == "__main__":
    main()
0