1408 - CS I2P 2018 Lee HW2 Scoreboard

Time

2018/03/13 15:30:00 2018/06/25 00:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11134 Swap number
11598 Word rotation

11134 - Swap number   

Description

In a shell game, balls with different numbers are hidden beneath identical containers, which are placed in a line. After the containers are shuffled, players need to guess the order of balls.

 

In this problem, there are five balls, numbered 0-4, and placed under five identical containers. The containers are placed in a straight line, and the initial positions of balls are from 0-4. The problem will then give k swaps of containers. Each swap is represented by a pair of integers, (a,b), meaning the container in position a is swapped with the container in position b. Your program needs to print the final ordering of balls.

 

For example, k=3, and three swaps are

0 4

2 3

1 2

 

Initially, the order of balls is: 0 1 2 3 4. After the swap (0,4), the order of balls becomes: 4 1 2 3 0; After the swap (2,3), the order of balls becomes: 4 1 3 2 0; and after the swap (1,2), the order of balls becomes:

4 3 1 2 0. So your program needs to print

4 3 1 2 0

 

hint:

To swap two numbers, a and b, you can use following code:

int temp;

temp = a;

a = b;

b = temp;

 

Input

The first line of the input is an integer k (0 < k < 25), which specifies the number of swaps. In the next k lines, each line contains a pair of integers, specifying the two positions to be swapped.

Output

The order of balls after swaps. Note that you do not need to print ‘\n’ at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11598 - Word rotation   

Description

    Given a string with length L < 1001 and only containing capital letters, lower letters and digits, please output the result of rotating the word for one time, and repeat doing so for L times.

    Suppose the original string is  ab1cde , after rotating for one time, the result will be  b1cdea. 

That is, the operator of rotating for one time is to move the first letter of the string to the tail of the string. 

 

Input

There is only one line in the input, which is a string only containing capital letters, lower letters and digits.

The length of the string L < 1001.

 

Output

    Output the result of rotating the word for one time, and repeat doing so for L times. The last line is the original string. Remember to print the endline character.

Sample Input  Download

Sample Output  Download

Tags




Discuss