結果

問題 No.2035 Tunnel
ユーザー あかしあみどりあかしあみどり
提出日時 2023-02-28 22:33:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,107 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 98,616 KB
最終ジャッジ日時 2023-10-14 04:58:43
合計ジャッジ時間 4,966 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,584 KB
testcase_01 AC 71 ms
71,520 KB
testcase_02 AC 71 ms
71,228 KB
testcase_03 AC 69 ms
71,308 KB
testcase_04 AC 70 ms
71,092 KB
testcase_05 AC 130 ms
89,864 KB
testcase_06 AC 130 ms
90,500 KB
testcase_07 AC 84 ms
76,712 KB
testcase_08 AC 99 ms
98,552 KB
testcase_09 AC 96 ms
98,332 KB
testcase_10 AC 99 ms
98,616 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 95 ms
81,080 KB
testcase_23 AC 81 ms
76,288 KB
testcase_24 AC 102 ms
84,432 KB
testcase_25 AC 105 ms
84,424 KB
testcase_26 AC 106 ms
84,592 KB
testcase_27 AC 120 ms
88,552 KB
testcase_28 AC 93 ms
80,820 KB
testcase_29 AC 78 ms
76,328 KB
testcase_30 AC 79 ms
76,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def oi(): return int(input())
def os(): return input()
def mi(): return list(map(int, input().split()))

# import sys
# input = sys.stdin.readline
# import sys
# sys.setrecursionlimit(10**8)
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
input_count = 0

from itertools import groupby

# RUN LENGTH ENCODING str -> list(tuple())
# example) "aabbbbaaca" -> [('a', 2), ('b', 4), ('a', 2), ('c', 1), ('a', 1)] 
def runLengthEncode(S: str) -> "List[tuple(str, int)]":
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, int(len(list(v)))))
    return res

input_count = 0
oi()
S = os()
def solve(S):
    dist = len(S)-S.index("#")-1

    run = runLengthEncode(S)
    if run[0][0] == "#":
        dist += run[0][1]
        ind = 1
    else:
        dist += run[1][1]
        ind = 2

    if run[-1][0] == ".":
        run = run[:-1]

    komi = 0
    if ind < len(run):
        for r in run[ind:]:
            if r[0] == ".":
                komi -= r[1]
            else:
                komi += r[1]
    dist += max(komi, 0)
    return (dist)

print(solve(S))
0