CF234A.Lefthanders and Righthanders

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

一个晴朗的十月天,数学老师瓦西里·彼得罗夫走进教室,发现有 nn 名学生坐在  desks 张课桌旁,每张课桌坐两人。瓦西里很快意识到 nn 是偶数。像所有真正的数学家一样,瓦西里将所有学生从 11 到 nn 编了号。

但瓦西里·彼得罗夫并不喜欢学生们当前在课桌上的就座方式。在他看来,编号相差 11 的学生不能坐在一起,因为他们会一直交谈,干扰他人并表现不佳。

另一方面,如果一名右手学生坐在课桌左侧位置,而一名左手学生坐在课桌右侧位置,则他们总会手肘相碰,彼此干扰。在其余所有情况下,坐在同一张课桌上的学生之间不会相互干扰。

瓦西里非常清楚哪些学生是左撇子、哪些是右撇子。他请你设计出任意一种满足上述两个简单条件(学生不互相交谈、也不手肘相碰)的就座方案。题目保证输入数据总存在至少一种可行的就座方式。

输入格式

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.

第一行输入包含一个唯一的偶数整数 nn(4 ≤ n ≤ 1004 \leq n \leq 100)——表示班级中的学生人数。
第二行包含恰好 nn 个大写英文字母 "L" 和 "R"。若第二行中第 ii 个字母为 "L",则编号为 ii 的学生是左撇子;否则,该学生为右撇子。

输出格式

Print 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.

输出 对整数,每行一对。在第 ii 行中,输出将坐在第 ii 张课桌上的学生编号。每对数中,第一个数表示坐在左侧的学生编号,第二个数表示坐在右侧的学生编号。每对数中的两个数字用空格分隔。若存在多种解,输出任意一种即可。

输入输出样例

  • 输入#1

    6
    LLRLLL

    输出#1

    1 4
    2 5
    6 3
  • 输入#2

    4
    RRLL

    输出#2

    3 1
    4 2

输入解题思路,AI测评打分。不知道怎么写?

首页