QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#16109. ICPC 추출기

Statistiques

신화의 생성이 시작되었다!

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.