1273 - CS I2P (II) 2017-2 Lee HW1 Scoreboard

Time

2017/09/19 12:00:00 2018/01/15 00:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11339 linked list-insert, erase and remove
11357 Josephus Problem

11339 - linked list-insert, erase and remove   

Description

This problem will ask you to do some operations on a list. These operations contains insert, erase, print, remove and show. The position of first node is 0.

Input

The input consist of a number of operations. The first line specifies a non-negative integer N that specifies the number of operations. Each operations (I, E, P, R and S) are separated by a newline character (\n).

I stands for “insert”, following by a non-negative integer (insert position) and a non-negative integer (insert value, 0<=insert value<65536). Insert a node at insert position with insert value.

E stands for “erase”, following by a non-negative integer (start position) and a non-negative integer (end position). End position must be greater than or equal to start position. Erase multiple nodes from start position to end position (excluding end position). If start position is equal to end position, do not erase end position.

If any input positions in the two operations above is greater than or equal to the length of the list, treat the input position as the next position of the last position at the list.

For example, input is

I 0 0

I 1 1

S

Output should be

0 1

P stands for “print”, following by a non-negative integer (print position). Print the value of the node at print position.

If print position is greater than or equal to the length of the list, treat the input position as the last position at the list.  If the
linked list is empty, do not print anything.

R stands for “remove”, following by a non-negative integer (remove value). Remove the nodes in the list with the value that is equal to remove value.

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.

For example, input is

5

E 1 1

E 1 2

P 2

R 1

S

Output should be nothing.

Output

Print a space after doing P or S operations (if P or S has printed something).

Sample Input  Download

Sample Output  Download

Partial Judge Code

11339.c

Partial Judge Header

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