結果
| 問題 |
No.204 ゴールデン・ウィーク(2)
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 18:47:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,652 bytes |
| コンパイル時間 | 224 ms |
| コンパイル使用メモリ | 82,392 KB |
| 実行使用メモリ | 54,316 KB |
| 最終ジャッジ日時 | 2025-06-12 18:47:47 |
| 合計ジャッジ時間 | 3,001 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 21 |
ソースコード
D = int(input())
week1 = input().strip()
week2 = input().strip()
S = week1 + week2 # 14 characters
# Precompute pre_o and suf_o
pre_o = 0
for c in S:
if c == 'o':
pre_o += 1
else:
break
suf_o = 0
for c in reversed(S):
if c == 'o':
suf_o += 1
else:
break
# Compute max_normal (without any changes)
max_normal = 0
current = 0
for c in S:
if c == 'o':
current += 1
max_normal = max(max_normal, current)
else:
current = 0
max_case1 = 0
if D > 0:
for i in range(14 - D + 1):
# Check if all D days are 'x'
valid = True
for j in range(i, i + D):
if S[j] != 'x':
valid = False
break
if not valid:
continue
# Create modified string
modified = list(S)
for j in range(i, i + D):
modified[j] = 'o'
modified_str = ''.join(modified)
# Find the maximum consecutive 'o' in modified_str
current_len = 0
max_len = 0
for c in modified_str:
if c == 'o':
current_len += 1
max_len = max(max_len, current_len)
else:
current_len = 0
max_case1 = max(max_case1, max_len)
max_case2 = 0
if D > 0:
if pre_o > 0:
case2 = D + pre_o
else:
case2 = D
max_case2 = case2
max_case3 = 0
if D > 0:
if suf_o > 0:
case3 = D + suf_o
else:
case3 = D
max_case3 = case3
if D == 0:
result = max_normal
else:
result = max(max_normal, max_case1, max_case2, max_case3)
print(result)
gew1fw