Rahul lucky-unlucky
Basic Accuracy: 24.56% Submissions: 963 Points: 1

Rahul is a geek. Head is the lucky call for him. You have to make him lucky. You are provided N coins. If the coin is heads facing upwards it means he is lucky else unlucky, your task is to do an operation to make him lucky. Operation allowed is as follows :
Starting from first element, if you find any coin heads facing downwards (Tail), flip the coin at ith index and (i+1)th index.  

Input:
The first line consists of T test cases. Each test case consists of 2 lines. The first line contains an integer N, denoting the number of coins. The second line contains N coins, represented by H or T (denoting head facing upwards and tail facing upwards respectively).

Output:
For each test case, output two lines where first line should contain number of flips, while next line contains indexes where coins have been flipped (starting index from 1). If no coin is flipped, second line prints "-1" (without quotes).

Constraints:
1 <= T <= 103
1 <= N <= 107

Example:
Input:

2
3
H H H

H T H T H
Output: 
0

-1
2
2 3

Explanation:
Testcase2:
Coins at index 2 and 3 needs to be flipped to make Rahul happy.

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.