結果
| 問題 |
No.1924 3 color painting on a line
|
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 16:31:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 422 bytes |
| コンパイル時間 | 357 ms |
| コンパイル使用メモリ | 82,276 KB |
| 実行使用メモリ | 69,420 KB |
| 最終ジャッジ日時 | 2025-04-16 16:32:59 |
| 合計ジャッジ時間 | 3,385 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 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)
lam6er