QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#16109. ICPC 抽出器

统计

神話の生成が始まった!

Ina に、文字 I、C、P のみからなる長さ $N$ の文字列 $S$ が与えられる。

彼女の仕事は、$S$ から部分文字列 ICPC をできるだけ多く繰り返し抽出することである。ICPC を抽出するたびに、$S$ から ICPC を構成する四つの文字を順番に選ばなければならない(連続している必要はないが、元の順序を守る必要がある)。抽出のたびに、選んだ文字は文字列から削除される。残った文字は隙間を詰め、次の抽出のための新しい文字列を作る。

彼女が ICPC を抽出できる最大回数と、各抽出で元の文字列 $S$ から削除される文字の添字(1 始まり)を求めるのを手伝わなければならない。

入力

最初の行には、テストケース数を表す整数 $t$ ($1 \le t \le 1000$) が一つ含まれる。

各テストケースには、文字 I、C、P のみからなる文字列 $S$ が一行に含まれる。

全テストケースにわたる $S$ の長さの合計は $2 \cdot 10^5$ を超えないことが保証される。

出力

各テストケースについて:

まず、ICPC を抽出できる最大回数を表す整数 $K$ を一行に出力せよ。

続いて $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.