結果
| 問題 |
No.1924 3 color painting on a line
|
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:18:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 627 bytes |
| コンパイル時間 | 277 ms |
| コンパイル使用メモリ | 82,944 KB |
| 実行使用メモリ | 67,328 KB |
| 最終ジャッジ日時 | 2025-06-12 15:18:46 |
| 合計ジャッジ時間 | 4,536 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 42 |
ソースコード
n = int(input())
s = input().strip()
if n == 0:
print(0)
exit()
# Count the number of runs and track the count of each color's runs
runs = 1
current_color = s[0]
color_run_counts = {current_color: 1}
for c in s[1:]:
if c != current_color:
runs += 1
current_color = c
if current_color in color_run_counts:
color_run_counts[current_color] += 1
else:
color_run_counts[current_color] = 1
# Calculate the number of colors with multiple runs
k = sum(1 for cnt in color_run_counts.values() if cnt >= 2)
# The answer is the number of runs minus k
print(runs - k)
gew1fw