結果

問題 No.457 (^^*)
ユーザー ebicochinealebicochineal
提出日時 2016-12-09 01:49:12
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 886 bytes
コンパイル時間 2,004 ms
コンパイル使用メモリ 86,492 KB
実行使用メモリ 77,008 KB
最終ジャッジ日時 2023-08-19 02:59:42
合計ジャッジ時間 5,895 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,076 KB
testcase_01 AC 70 ms
71,116 KB
testcase_02 AC 71 ms
71,264 KB
testcase_03 AC 69 ms
71,192 KB
testcase_04 AC 71 ms
71,004 KB
testcase_05 AC 70 ms
70,964 KB
testcase_06 AC 79 ms
74,868 KB
testcase_07 AC 98 ms
76,592 KB
testcase_08 AC 162 ms
77,008 KB
testcase_09 AC 558 ms
76,696 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    def f(s, e, n, m, lcnt, rcnt):
        l1 = l2 = r1 = r2 = 0
        for i in S[s:e]:
            if i == '*':
                r1 = 1
                if l2>1 : l1 = 1
            elif i == '^':
                if r1 : r2 += 1
                l2 += 1
        if l1 : lcnt += n*m
        if r2 > 1 : rcnt += n*m
        return lcnt, rcnt
    
    S = input()
    l, r = [], []
    lc = rc = 0
    lcnt = rcnt = 0
    for i in range(len(S)):
        if S[i] == '(':
            lc += 1
        else:
            if lc > 0 : l += [(i, lc)]
            lc = 0
        if S[i] == ')' :
            rc += 1
        else:
            if rc > 0 : r += [(i-1, rc)]
            rc = 0
    if rc > 0 : r += [(len(S)-1, rc)]
    
    for s, n in l:
        for e, m in r:
            lcnt, rcnt = f(s, e, n, m, lcnt, rcnt)
    print(lcnt, rcnt)

if __name__ == '__main__':
    main()
0