結果
問題 |
No.1924 3 color painting on a line
|
ユーザー |
![]() |
提出日時 | 2025-04-16 00:50:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 422 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 81,760 KB |
実行使用メモリ | 69,444 KB |
最終ジャッジ日時 | 2025-04-16 00:52:22 |
合計ジャッジ時間 | 3,699 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 42 |
ソースコード
n = int(input()) s = input().strip() if n == 0: print(0) exit() # Count the number of color changes when moving from right to left count = 1 prev = s[-1] for i in range(n-2, -1, -1): if s[i] != prev: count += 1 prev = s[i] # Count the number of times a color is the same as two positions to the right d = 0 for i in range(n-3, -1, -1): if s[i] == s[i+2]: d += 1 print(count - d)