#P3677. [CERC2016] 关键的膝盖 Key Knocking
[CERC2016] 关键的膝盖 Key Knocking
Description
Goran is recovering from knee surgery and is experimenting with smart card encryption keys for storage. In this problem, a key is a binary sequence of length , where is a positive integer. The bits of the sequence are numbered from left to right as to . The weight of a key is defined as the number of positions where adjacent bits differ, plus . For example, the weight of "000" is , and the weight of "011010100" is .
He finds that he can send small current pulses to modify the circuits of the smart card, thereby modifying the key. Specifically, he can repeatedly perform the following operation: choose any two adjacent bits and flip them both. For example, he can change "000" to "110" in one operation.
Given a key of length , perform at most operations to transform it into a key with weight at least . You may assume that a valid solution always exists.
Input Format
One line containing a binary string representing the initial key. Its length is exactly , where .
Output Format
The first line contains an integer denoting the number of operations, with .
The second line contains positive integers (), in order indicating that in the -th operation you flip bits at positions and .
If the initial key already has weight at least , you may output a single line containing the integer .
111001000111
2
3 9
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号