結果
問題 |
No.1924 3 color painting on a line
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:07:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 627 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 81,740 KB |
実行使用メモリ | 68,840 KB |
最終ジャッジ日時 | 2025-06-12 20:14:03 |
合計ジャッジ時間 | 3,176 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)