結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー rlangevin
提出日時 2023-01-09 23:03:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 1,000 ms
コード長 657 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 67,888 KB
最終ジャッジ日時 2024-12-18 00:29:45
合計ジャッジ時間 4,056 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(S):
    cnt = 0
    N = len(S)
    ans = 0
    for i in range(N):
        if S[i] == "o":
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    return max(ans, cnt)

D = int(input())
C = ["x"] * 14
C.extend(list(input()))
C.extend(list(input()))
C.extend(["x"] * 14)
N = len(C)
ans = calc(C)
for d in range(1, D + 1):
    for i in range(N):
        if C[i:i+d] == ["x"] * d:
            temp = [None] * N
            for j in range(N):
                if i <= j < i + d:
                    temp[j] = "o"
                else:
                    temp[j] = C[j]
            ans = max(ans, calc(temp))
print(ans)
0