結果
問題 |
No.1924 3 color painting on a line
|
ユーザー |
![]() |
提出日時 | 2025-04-16 16:29:17 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 451 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 70,144 KB |
最終ジャッジ日時 | 2025-04-16 16:30:26 |
合計ジャッジ時間 | 4,582 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 42 |
ソースコード
n = int(input()) s = input().strip() # Check if all characters are the same if all(c == s[0] for c in s): print(1) else: dp = [0] * (n + 1) last = {'R': -1, 'G': -1, 'B': -1} for i in range(n): c = s[i] option1 = dp[i] + 1 if last[c] == -1: option2 = float('inf') else: option2 = dp[last[c] + 1] + 1 dp[i + 1] = min(option1, option2) last[c] = i print(dp[n])