PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000073. Xóa xâu hai bước (String Deletion)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Xóa xâu hai bước (String Deletion)
String Deletion
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a binary string, each operation must delete one arbitrary character and then, if nonempty, delete its maximum equal-character prefix. Maximize the number of operations before the string becomes empty.
Input
Line 1: . Line 2: binary string . Exactly one case, without .
Output
Print the maximum possible number of operations.
Subtasks
- Subtask 1 (20 points): Exactly one dataset; ; the string contains exactly binary characters.
- Subtask 2 (30 points): Exactly one dataset; ; the string contains exactly binary characters.
- Subtask 3 (50 points): Exactly one dataset; ; the string contains exactly binary characters.
Example
Input
6
111010
Output
3
Explanation
Deleting a character then the maximal equal prefix can be repeated three times on 111010.