codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

234A.md (2326B)


      1 Source: https://codeforces.com/problemset/problem/234/A
      2 
      3 A. Lefthanders and Righthanders
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 input.txt
     16 
     17 output
     18 
     19 output.txt
     20 
     21 One fine October day a mathematics teacher Vasily Petrov went to a class and saw there *n* pupils who sat at the ![](https://espresso.codeforces.com/a64c1b2df604f8cfa9acf6716a3cc1424488361e.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*.
     22 
     23 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.
     24 
     25 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.
     26 
     27 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.
     28 
     29 Input
     30 
     31 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.
     32 
     33 Output
     34 
     35 Print ![](https://espresso.codeforces.com/a64c1b2df604f8cfa9acf6716a3cc1424488361e.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.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 6  
     43 LLRLLL
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 1 4  
     50 2 5  
     51 6 3
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 4  
     58 RRLL
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 3 1  
     65 4 2
     66 ```