QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 100

#11099. 敲击键盘

Statistiques

Goran 正在从膝盖手术中康复,他正在试验一张用于存储加密密钥的智能卡。在本题中,密钥是一个长度为 $3n$ 的位串,其中 $n$ 是一个正整数。密钥的特定位从左到右依次用 $1$ 到 $3n$ 的整数进行索引。密钥的权值定义为相邻位不同的对数加 $1$。例如,密钥 “000” 的权值为 $1$,而密钥 “011010100” 的权值为 $7$。

他发现可以通过向智能卡的电路发送微小的电流脉冲来篡改密钥。具体来说,他可以可靠地执行以下操作:选择任意两个相邻的位并将它们同时翻转。例如,一次操作可以将密钥 “000” 变为 “110”。

给定一个长度为 $3n$ 的密钥,请找到一个至多包含 $n$ 次操作的序列,将给定的密钥转换为权值至少为 $2n$ 的密钥。你可以假设解总是存在的。

输入格式

第一行包含一个由数字 “0” 和 “1” 组成的字符串,即初始密钥。密钥的长度为 $3n$,其中 $n$ 是一个正整数,满足 $1 \le n \le 100\,000$。

输出格式

第一行应包含一个整数 $m$($0 \le m \le n$),表示你方案中的操作次数。下一行应包含 $m$ 个整数 $a_1, a_2, \dots, a_m$,描述你的方案。数字 $a_k$ 表示在第 $k$ 步中被翻转的两个相邻位中左侧那个位的索引。

如果初始密钥的权值已经至少为 $2n$,你只需输出整数 $0$。

样例

样例输入 1

000000000

样例输出 1

3
2 5 6

样例输入 2

111001000111

样例输出 2

2
3 9

样例输入 3

010101

样例输出 3

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.