Feeding Beavers
시간 제한2.5초메모리 제한256 MB
2N개의 접시를 N마리의 비버에게 둘씩 나눠 주되, 비버 번호가 커질수록 만족도의 합이 작아지지 않고 각 합의 홀짝이 주어진 문자열과 일치하도록 배정하고, 가능하면 그 예를 출력한다.
문제
It’s dinner time, and Busy Beaver has to feed his baby beavers.
Busy Beaver has baby beavers, numbered from to . The older baby beavers have bigger indices than the younger ones; for example, beaver is the youngest while beaver is the oldest.
Busy Beaver also has dishes, which are numbered from to . If a beaver eats dish , its satisfaction will increase by . Each beaver starts with satisfaction.
Now, Busy Beaver wants to distribute the dishes amongst his baby beavers subject to the following constraints:
- Each beaver should get exactly two dishes.
- After all dishes are consumed, older beavers should have at least as much satisfaction as younger beavers. Formally, for any with , beaver ’s satisfaction should not exceed beaver ’s satisfaction.
- The parity of beaver ’s satisfaction should be (odd or even).
Determine if there exists a way to feed all beavers that respects these constraints. Additionally, if the task is possible, print any valid assignment of dishes to beavers.
입력
Each test contains multiple test cases. The first line contains a single integer () --- the number of test cases. The description of each test case follows.
The first line of each test case contains an integer () --- the number of baby beavers.
The second line of each test case contains a string of length , where each of the characters is either ‘O’ or ‘E’. If is ‘O’, the beaver wants its satisfaction to be an odd number. If is ‘E’, the beaver wants its satisfaction to be an even number.
It is guaranteed that the sum of across all test cases is no more than .
출력
For each test case, if it is possible to feed the beavers, output “YES” (without quotes) on the first line. Next, print lines describing how to feed each beaver. The -th of these lines should contain two integers, which denote the indices of the two dishes that will be given to beaver .
If it is impossible to feed the beavers, output “NO” (without quotes).
You can output “YES” and “NO” in any case. (For example, strings “yES”, “yes” and “Yes” will be recognized as a positive response.)