結果

問題 No.457 (^^*)
ユーザー titiatitia
提出日時 2023-08-10 01:30:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 551 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 82,104 KB
実行使用メモリ 70,036 KB
最終ジャッジ日時 2024-04-27 19:15:45
合計ジャッジ時間 3,382 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,288 KB
testcase_01 AC 31 ms
52,860 KB
testcase_02 AC 32 ms
52,520 KB
testcase_03 AC 32 ms
52,756 KB
testcase_04 AC 32 ms
53,124 KB
testcase_05 AC 30 ms
52,680 KB
testcase_06 AC 32 ms
53,040 KB
testcase_07 AC 37 ms
52,692 KB
testcase_08 AC 44 ms
62,144 KB
testcase_09 AC 48 ms
65,528 KB
testcase_10 AC 54 ms
68,324 KB
testcase_11 AC 59 ms
68,416 KB
testcase_12 AC 337 ms
70,036 KB
testcase_13 AC 551 ms
68,424 KB
testcase_14 AC 40 ms
59,868 KB
testcase_15 AC 332 ms
68,772 KB
testcase_16 AC 543 ms
67,524 KB
testcase_17 AC 40 ms
61,024 KB
testcase_18 AC 32 ms
53,144 KB
testcase_19 AC 32 ms
53,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()

LEFT=[0]*(len(S)+1)
RIGHT=[0]*(len(S)+1)

for i in range(len(S)):
    if S[i]=="(":
        LEFT[i]=LEFT[i-1]+1
    else:
        LEFT[i]=LEFT[i-1]

for i in range(len(S)-1,-1,-1):
    if S[i]==")":
        RIGHT[i]=RIGHT[i+1]+1
    else:
        RIGHT[i]=RIGHT[i+1]

ANSL=0
ANSR=0

for i in range(len(S)):
    if S[i]=="(":
        x=0

        for j in range(i+1,len(S)):
            if x==0 and S[j]=="*":
                x+=1
            elif 1<=x<=2 and S[j]=="^":
                x+=1

            if x==3:
                ANSR+=RIGHT[j]
                #print(i,j)
                break

        x=0
        for j in range(i+1,len(S)):
            if x<=1 and S[j]=="^":
                x+=1
            elif x==2 and S[j]=="*":
                x+=1

            if x==3:
                ANSL+=RIGHT[j]
                #print(i,j)
                break

print(ANSL,ANSR)
0