Lefthanders and Righthanders(CF-234A)

Problem Description

One fine October day a mathematics teacher Vasily Petrov went to a class and saw there n pupils who sat at the desks, two people at each desk. Vasily quickly realized that number n is even. Like all true mathematicians, Vasily has all students numbered from 1 to n.

But Vasily Petrov did not like the way the children were seated at the desks. According to him, the students whose numbers differ by 1, can not sit together, as they talk to each other all the time, distract others and misbehave.

On the other hand, if a righthanded student sits at the left end of the desk and a lefthanded student sits at the right end of the desk, they hit elbows all the time and distract each other. In other cases, the students who sit at the same desk, do not interfere with each other.

Vasily knows very well which students are lefthanders and which ones are righthanders, and he asks you to come up with any order that meets these two uncomplicated conditions (students do not talk to each other and do not bump their elbows). It is guaranteed that the input is such that at least one way to seat the students always exists.

Input

The first input line contains a single even integer n (4 ≤ n ≤ 100) — the number of students in the class. The second line contains exactly n capital English letters "L" and "R". If the i-th letter at the second line equals "L", then the student number i is a lefthander, otherwise he is a righthander.

Output

Print n/2 integer pairs, one pair per line. In the i-th line print the numbers of students that will sit at the i-th desk. The first number in the pair stands for the student who is sitting to the left, and the second number stands for the student who is sitting to the right. Separate the numbers in the pairs by spaces. If there are multiple solutions, print any of them.

Examples

Input

6
LLRLLL

Output

1 4
2 5
6 3

Input

4
RRLL

Output

3 1
4 2

题意:n 个人,每个人分左撇子和右撇子,从后向前编号分别为 1~n,现在要求每两个人坐在一起,坐在一起的两人的编号要大于 1,且如果一个左撇子与一个右撇子坐在一起的话,左撇子不能坐在右端,右撇子不能坐在左端

思路:思维

从前向后扫一遍,判断第 i 个人是左撇子还是右撇子,如果第 i 个人是左撇子,让他坐在左端,如果第 i 个人是右撇子,让他坐在右端,然后与他们一起坐的那个人,无论是左撇子还是右撇子均可满足,此时只需要扫描到 n/2,然后让第 i 个人与第 i+n/2 个人坐在一起即可

此外,要注意使用文件读写

Source Program

#include<bits/stdc++.h>
#define Exp 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 10000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
char str[N];
int main(){
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int n;
    scanf("%d",&n);
    scanf("%s",str+1);
    int pos=n/2;
    for(int i=1;i<=pos;i++){
        if(str[i]=='L')
            printf("%d %d\n",i,i+pos);
        else if(str[i]=='R')
            printf("%d %d\n",i+pos,i);
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值