結果
| 問題 | No.3114 0→1 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 16:51:55 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 46 ms / 2,000 ms |
| + 155µs | |
| コード長 | 461 bytes |
| 記録 | |
| コンパイル時間 | 55 ms |
| コンパイル使用メモリ | 14,464 KB |
| 実行使用メモリ | 13,440 KB |
| 最終ジャッジ日時 | 2026-10-21 08:26:09 |
| 合計ジャッジ時間 | 3,880 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge6_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
def count_and_update(s):
s_list = list(s)
count = 0
for i in range(len(s_list)):
if s_list[i] == '0':
if (i >= 1 and s_list[i - 1] == '0') or (i >= 2 and s_list[i - 2] == '0'):
count += 1
s_list[i] = '1' # 条件に合ったら '1' に変更
updated_s = ''.join(s_list)
return count, updated_s
n = int(input())
s = input().strip()
count, updated_s = count_and_update(s)
print(count)