結果

問題 No.457 (^^*)
ユーザー htkbhtkb
提出日時 2018-05-25 10:52:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 586 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 12,692 KB
最終ジャッジ日時 2023-09-11 03:22:36
合計ジャッジ時間 4,170 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,912 KB
testcase_01 AC 16 ms
7,960 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 AC 16 ms
7,844 KB
testcase_07 WA -
testcase_08 AC 17 ms
7,844 KB
testcase_09 AC 19 ms
7,852 KB
testcase_10 WA -
testcase_11 AC 32 ms
8,300 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
p_cumsum = [0]*(len(S)+1)
for c, i in zip(S[::-1], range(len(S)-1, -1, -1)):
    p_cumsum[i] = p_cumsum[i+1] + (c == ")")

right, left = "* ^ ^".split(), "^ ^ *".split()
result = [0, 0]
for i, c in enumerate(S):
    if c != "(":
        continue
    for j, parts in enumerate((left, right)):
        p_i, p_c = 0, parts[0]
        for k, c2 in enumerate(S[i+1:], start=i+1):
            if c2 == p_c:
                p_i += 1
                if p_i > 2:
                    break
                p_c = parts[p_i]
        result[j] += p_cumsum[k]

print(result[0], result[1])
0