結果
| 問題 |
No.1924 3 color painting on a line
|
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:47:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 381 bytes |
| コンパイル時間 | 498 ms |
| コンパイル使用メモリ | 82,412 KB |
| 実行使用メモリ | 72,388 KB |
| 最終ジャッジ日時 | 2025-06-12 14:50:25 |
| 合計ジャッジ時間 | 3,684 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 43 |
ソースコード
n = int(input())
s = input().strip()
if n == 0:
print(0)
exit()
# Split the string into runs of the same color
runs = []
prev = s[0]
runs.append(prev)
for c in s[1:]:
if c != prev:
runs.append(c)
prev = c
count = len(runs)
# If the first and last runs are the same, subtract one
if len(runs) > 1 and runs[0] == runs[-1]:
count -= 1
print(count)
gew1fw