結果

問題 No.457 (^^*)
ユーザー Mr.FukuMr.Fuku
提出日時 2018-08-08 22:24:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,520 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 11,988 KB
実行使用メモリ 10,596 KB
最終ジャッジ日時 2023-10-24 11:45:21
合計ジャッジ時間 1,801 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

s = list(input())
len_s = len(s)
close_list = [0]*len_s
face_l = []
face_r = []
cnt_l = 0
cnt_r = 0

def readface():
    global face
    fa_l = []
    fa_r = []
    close_cnt = 0
    for i in range(len_s-1,-1,-1):
        x = s[i]
        if x==")":
            close_cnt+=1
        elif x=="^":
            if len(fa_l)>0:
                fa_l.append(i)
                if len(fa_l)==3:
                    face_l.append([fa_l[-1],fa_l[0]])
                    fa_l = []
            fa_r.append(i)
        elif x=="*":
            if len(fa_l)==0:
                fa_l.append(i)
            if len(fa_r)>1:
                fa_r.append(i)
                face_r.append([fa_r[-1],fa_r[-3]])
                fa_r = []
        close_list[i]=close_cnt

def delmin(n):
    global face_l,face_r
    d_list = []
    for i in range(len(face_l)):
        if face_l[i][0]<n:
            d_list.append(i)
        else:
            break
    d_list.reverse()
    for i in d_list:
        del face_l[i]
        
    d_list = []
    for i in range(len(face_r)):
        if face_r[i][0]<n:
            d_list.append(i)
        else:
            break
    d_list.reverse()
    for i in d_list:
        del face_r[i]

def check(light):
    global cnt_l,cnt_r
    if len(face_l)>0:
        cnt_l += close_list[face_l[0][1]]
    if len(face_r)>0:
        cnt_r += close_list[face_r[0][1]]

readface()
face_l.sort()
face_r.sort()
for light in range(len_s):
    if s[light]=="(":
        delmin(light)
        check(light)
print(cnt_l,cnt_r)
0