結果

問題 No.457 (^^*)
ユーザー h_nosonh_noson
提出日時 2017-01-26 17:35:19
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 76,972 KB
最終ジャッジ日時 2023-08-25 00:02:58
合計ジャッジ時間 3,069 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,252 KB
testcase_01 AC 76 ms
71,256 KB
testcase_02 AC 74 ms
71,316 KB
testcase_03 AC 74 ms
71,100 KB
testcase_04 AC 77 ms
71,364 KB
testcase_05 AC 76 ms
71,260 KB
testcase_06 AC 76 ms
71,260 KB
testcase_07 AC 88 ms
76,228 KB
testcase_08 AC 88 ms
76,108 KB
testcase_09 AC 98 ms
76,152 KB
testcase_10 AC 127 ms
76,620 KB
testcase_11 AC 224 ms
76,972 KB
testcase_12 AC 92 ms
76,200 KB
testcase_13 AC 84 ms
75,672 KB
testcase_14 AC 84 ms
76,036 KB
testcase_15 AC 91 ms
76,128 KB
testcase_16 AC 83 ms
75,612 KB
testcase_17 AC 88 ms
75,872 KB
testcase_18 AC 78 ms
71,368 KB
testcase_19 AC 81 ms
71,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
left = "(^^*)"
right = "(*^^)"

ans = 0
i = 0
while i < len(s):
    if s[i] == '(':
        add = 0
        while i < len(s) and s[i] == '(':
            i += 1
            add += 1
        state = 1
        for j in range(i,len(s)):
            if state < len(left)-1 and s[j] == left[state]:
                state += 1
            elif s[j] == left[state]:
                ans += add
    i += 1
print(ans,end=" ")

ans = 0
i = 0
while i < len(s):
    if s[i] == '(':
        add = 0
        while i < len(s) and s[i] == '(':
            i += 1
            add += 1
        state = 1
        for j in range(i,len(s)):
            if state < len(right)-1 and s[j] == right[state]:
                state += 1
            elif s[j] == right[state]:
                ans += add
    i += 1
print(ans)
0