結果

問題 No.3308 One-time Changed Formula
コンテスト
ユーザー fungsi
提出日時 2025-10-28 17:30:56
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 1,278 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2025-10-28 17:31:00
合計ジャッジ時間 2,727 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

def process_string(s: str) -> int:
    ans = 0
    shift_flag = False

    for ch in s:
        if ch.isdigit():
            digit = int(ch)
            ans += digit - 1 if shift_flag else 9 - digit
        elif ch == '*':
            if not shift_flag:
                ans += 9
        elif ch == '-':
            if not shift_flag:
                ans += 9
            shift_flag = True
        elif ch == '+':
            if not shift_flag:
                ans += 9
            shift_flag = False

    return ans

def main():
    t = int(input())
    for _ in range(t):
        n, s = input().split()
        print(process_string(s))

0