1153 - CS I2P (II) 2017 Lee Quiz2 Scoreboard

Time

2017/03/10 13:20:00 2017/03/10 15:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11355 insert and sort
11357 Josephus Problem

11355 - insert and sort   

Description

You are required to do sorting after inserting an element.

Input

The first line contains a non-negative integer N that specifies the number of testcases. The first line of testcases contains a non-negative integer P (0<=op count<65536that specifies the number of operations. The second line for testcases contains operations. Each operations (C, I or S) are separated by a space. Each testcases are separated by a newline character (\n).

C stands for “clear”. Free all nodes in the list.

I stands for “insert and sort”, following by a non-negative integer (insert value, 0<=insert value<65536). Insert a node and sort the list. Sort the list in ascending order. (Hint: You can insert a node on the appropriate position.)

S stands for “show”. Print the value of all nodes in the list. Separate every prints by a whitespace character. If the list is empty, do not print anything.

Output

Print a space after doing S operations (if S has printed something).
e.g. If linked list has 2 elements (1, 2), print "1 2 ".

Sample Input  Download

Sample Output  Download

Partial Judge Code

11355.c

Partial Judge Header

11355.h

Tags




Discuss




11357 - Josephus Problem   

Description

Based on the original Josephus Problem introduced in class, this problem adds other rules.

1. After killing a person, it will change the direction of counting.

2. After killing a person, the counting number will increase the same value.

For example, there are 5 people, numbered 1 to 5, in a circle

and arranged in clockwise.  The step to kill is 3.

1, 2, 3 (kill 3, change the direction to counter-clockwise)

2, 1, 5, 4, 2, 1 (kill 1, change the direction to clockwise)

2, 4, 5, 2, 4, 5, 2, 4, 5 (kill 5, change the direction to counter-clockwise)

...

 

Input

The input has two positive integers, n (the number of people) and m (the number that will increase every time).

Output

The output is the order of people that were killed.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11357.c

Partial Judge Header

11357.h

Tags




Discuss