結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー GrayCoder
提出日時 2018-08-17 01:15:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 1,000 ms
コード長 872 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-05 07:19:48
合計ジャッジ時間 3,124 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin, stdout

input = lambda: stdin.readline()
write = stdout.write

def longest(seq):
    max_count = 0
    prev_char = None
    for current in seq:
        if current == 'x':
            prev_char = 'x'
            continue
        if prev_char != current:
            count = 1
        else:
            count += 1
        if count > max_count:
            max_count = count
        prev_char = current
    return max_count

def main():
    D = int(input())
    C = stdin.read().splitlines()

    c = ['x'] * 14 + list(C[0]) + list(C[1]) + ['x'] * 14
    gw = longest(c)
    if not D:
        print(gw)
        return
    for i in range(56 - D):
        s = ''.join(c[i:i+D]).split('o')
        n = sum(map(bool, s))
        if n == 1:
            c_ = c[:]
            c_[i:i+D] = ['o'] * D
            gw = max(gw, longest(c_))
    print(gw)

main()
0