301247: CF234A. Lefthanders and Righthanders

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Lefthanders and Righthanders

题意翻译

一位数学老师 Vasily Petrov 去上课,看到有 $n$ 个学生坐在 $\dfrac{n}{2}$ 张课桌前,每张课桌上有 $2$ 名学生。 Vasily Petrov 发现,$n$ 是一个偶数,于是 Vasily Petrov 把所有的学生都从 $1$ 到 $n$ 编号,即第一个学生标号为 $1$,第二个为 $2$,以此类推。 但 Vasily Petrov 不喜欢孩子们的座位排列顺序。 他的排列方式如下: - 编号相差 $1$ 的学生(如 $1$ 号和 $2$ 号,$2$ 号和 $3$ 号)不能坐在一起; - 如果一个右撇子的学生坐在桌子的左侧,一个左撇子的学生坐在桌子的右侧,他们也不能坐在一起。 Vasily Petrov 很清楚哪些学生是左撇子,哪些学生是右撇子,请你帮助 Vasily Petrov 安排座位,数据保证至少有 $1$ 种安排座位的方式。 请在提交时加上文件读写,以下是 C++ 语言的示例: ```cpp #include <bits/stdc++.h> using namespace std; int main() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); // ... return 0; } ``` by [219791](/user/219791).

题目描述

One fine October day a mathematics teacher Vasily Petrov went to a class and saw there $ n $ pupils who sat at the ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF234A/666f6519688863e0a36337875170dd12050e1c31.png) 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.

输入输出格式

输入格式


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.

输出格式


Print ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF234A/666f6519688863e0a36337875170dd12050e1c31.png) 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.

输入输出样例

输入样例 #1

6
LLRLLL

输出样例 #1

1 4
2 5
6 3

输入样例 #2

4
RRLL

输出样例 #2

3 1
4 2

Input

题意翻译

一位数学老师 Vasily Petrov 去上课,看到有 $n$ 个学生坐在 $\dfrac{n}{2}$ 张课桌前,每张课桌上有 $2$ 名学生。 Vasily Petrov 发现,$n$ 是一个偶数,于是 Vasily Petrov 把所有的学生都从 $1$ 到 $n$ 编号,即第一个学生标号为 $1$,第二个为 $2$,以此类推。 但 Vasily Petrov 不喜欢孩子们的座位排列顺序。 他的排列方式如下: - 编号相差 $1$ 的学生(如 $1$ 号和 $2$ 号,$2$ 号和 $3$ 号)不能坐在一起; - 如果一个右撇子的学生坐在桌子的左侧,一个左撇子的学生坐在桌子的右侧,他们也不能坐在一起。 Vasily Petrov 很清楚哪些学生是左撇子,哪些学生是右撇子,请你帮助 Vasily Petrov 安排座位,数据保证至少有 $1$ 种安排座位的方式。 请在提交时加上文件读写,以下是 C++ 语言的示例: ```cpp #include <bits/stdc++.h> using namespace std; int main() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); // ... return 0; } ``` by [219791](/user/219791).

加入题单

上一题 下一题 算法标签: