QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#16109. ICPC Extractor

統計

神话的创造已经开始!

Ina 得到了一个长度为 $N$ 的字符串 $S$,该字符串仅由字符 'I'、'C' 和 'P' 组成。

她的任务是从 $S$ 中尽可能多次地提取子串 "ICPC"。每次提取 "ICPC" 时,她必须从 $S$ 中按顺序(不一定连续,但必须保持原始顺序)选择四个字符,使其构成 "ICPC"。每次提取后,所选字符将从字符串中移除。剩余字符会闭合空隙,形成用于下一次提取的新字符串。

你需要帮助她确定提取 "ICPC" 的最大次数,以及每次提取时被移除字符在原始字符串 $S$ 中的下标(从 1 开始计数)。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 1000$),表示测试用例的数量。

每个测试用例包含一行字符串 $S$,仅由字符 'I'、'C' 和 'P' 组成。

保证所有测试用例中 $S$ 的长度之和不超过 $2 \cdot 10^5$。

输出格式

对于每个测试用例:

首先,输出一行一个整数 $K$,表示提取 "ICPC" 的最大次数。

然后输出 $K$ 行,每行包含四个整数,表示该次提取中被移除的字符在原始字符串中的位置。

如果存在多种提取方式,输出其中任意一种即可。

样例

输入 1

4
PICPPC
ICPICPCCI
CIPCICICPPCCP
IPCC

输出 1

1
2 3 5 6
2
1 2 3 7
4 5 6 8
2
2 4 9 11
5 6 10 12
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.