結果

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

ソースコード

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 = list(C[0]) + list(C[1])
    gw = longest(c)
    if not D:
        print(gw)
        return
    for i in range(15 - D):
        c_ = c[:]
        if not 'o' in c_[i:i+D]:
            c_[i:i+D] = ['o'] * D
            gw = max(gw, longest(c_))
    print(gw)

main()
0