結果

問題 No.457 (^^*)
コンテスト
ユーザー ヒッキープログラミングするスレ GitHub ガチ
提出日時 2016-12-08 02:49:23
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 339 ms / 2,000 ms
コード長 679 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 242 ms
コンパイル使用メモリ 85,632 KB
実行使用メモリ 80,896 KB
最終ジャッジ日時 2026-05-22 07:53:33
合計ジャッジ時間 3,167 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

s = input()

def solve(s):
    left = 0
    right = 0
    
    for i in range(len(s)):
        if s[i] != '(':
            continue
        lfc = 0
        rfc = 0
        for j in range(i + 1, len(s)):
            if s[j] == '^':
                if lfc < 2:
                    lfc += 1
                if rfc > 0:
                    rfc += 1
            elif s[j] == '*':
                if lfc == 2:
                    lfc = 3
                if rfc == 0:
                    rfc = 1
            elif s[j] == ')':
                if lfc > 2:
                    left += 1
                if rfc > 2:
                    right += 1
    return [left, right]


print(*solve(s))
0