2741 - I2P(II)2023_Yang_hw1 Scoreboard

Time

2023/02/17 15:20:00 2023/03/10 13:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12668 Text Editor - Linked List Version
12680 Card Magic
13442 Lucky money 2
13825 The Last of DYY's Hamon

12668 - Text Editor - Linked List Version   

Description

Modified from 10389 - text editor

In this problem we simulate a simple text editor. Given a series of keyboard input, output the final text content. Initially, the text content is empty and the cursor is at the beginning of the line. The user can:

  1. Insert a lower-case alphabet ('a-z') before the cursor, denoted as a lower-case alphabet.

  2. Erase an alphabet before the cursor, denoted as B.

  3. Move the cursor to the right one character at a time, denoted as R.

  4. Move the cursor to the left one word at a time, denoted as L.

Hints

In this problem, you are asked to use doubly linked list to reduce the time complexity. Three typical implementations as follows are possible. You can choose your favorite one, e.g., Impl 1 or Impl 2.

Remember to free memory when a linked list node is deleted. If you get Runtime Error on test case, probably there is something wrong with the pointers or there is memory leak in your program.

Make sure the time complexity is O(1) for each operation, otherwise you may get Time limit exceed

Input

The first line is an integer T (1 <= T <= 50), meaning that there are T subtasks in the input.

In each subtask, there are two lines. The first line is an integer N(1<= N <= 106), being the length of the series of keyboard input. The next line is a string of length N, being the series of keyboard input.

It is guaranteed that L and B will not occur when the cursor is in the left-most position, R will not occur when the cursor is in the right-most position.

Output

For each subtask, output the final text content in a single line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12680 - Card Magic   

Description

Mr. Lu is a famous magician. There’s a poker magic tutorial on his youtube channel.
There’re N stacks of cards on the table at begining.
And then, Mr. Lu make M actions on these card stacks.
There’s only two kinds of actions Merge and Cut:

  • Merge x y: put the x-th card stack on the top of y-th card stack.
  • Cut x i: cut the x-th card stack into two stacks. One is the card stack contains ( 1~i )-th cards of original stack. The other one is the remaining. The former’s index will be x, the latter’s will be (x+1)
  • The indexes of stacks and cards will be changed after Merge and Cut.

For example:

As a lazy CS student, you only focus on the result.
Therefore, you decide to write a program to compute the final state of card stacks.

It’s partial judge for this problem.
Please download the code at the bottom to see the interface and main function.
You have to implement a data structure like below:

Input

Two integer N,M on the first line.
For each of the next N lines, there’re several integers Ni and Ci,1,Ci,2...Ci,Ni.
Ni means the number of cards in the i-th stack.
Ci,j denotes the j-th card of i-th stack.

The folloing M lines contains one action per line.
Every Action is one of “Merge x y” or “Cut x i”.

It’s guaranteed that:

  • ≤ N≤ 9000
  • ∑ N≤ 4104
  • Ci,j is non-negative integer.
  • In “Merge x y” action:
    • the x, y-th stacks always exist.
    • x is not equal to y.
  • In “Cut x i” action:
    • the x-th stack always exists.
    • i is always between 1 and Nx - 1.
  • There’s at least 1 card in each card stack.

Output

Print the card stacks by the order of index.
One line for one card stack.

Please refer to the sample input/output for the precise format.
There is a ‘\n’ at the end of each line.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12680.c

Partial Judge Header

12680.h

Tags




Discuss




13442 - Lucky money 2   

Description

Receiving lucky money is the favorite activity of children during Chinese New Year.

Denny's family has N children, everyone wants to get the lucky money as soon as possible.

The elders in the family have prepared a game to decide the order of receiving the lucky money:

  • At the beginning, all children sit in a circle, with seats numbered from 1 to N.
  • Randomly decide two numbers A and K and the direction R/L, move the Ath youngest child K positions clockwise/counterclockwise.

For example:

N = 6

The given initial age sequence: 1 1 3 4 5 5

 

 

A = 3, K = 2, R

After processing:

 

 

A = 1, K = 3, L

After processing:

 

 

A = 1, K = 6, R

After processing:

 

 

A = 2, K = 2, R

After processing:

 

Output:
The age sequence in clockwise from the youngest: 1 3 5 4 5 1

Note: if two children have same age, consider the children with less order yonger.

 

Input

The first line contains two integers N M, the number of children and the number of position changes.

The second line contains N integers, giving the children's age sequence.

Each of the following M lines contains two integers A and K and the direction 'R' or 'L'.

 

test cases:

(3/8) 1 <= A <= N <= 100, 1 <= M, K <= 100, all children are different ages, and the age sequence is {1, 2, ..., N}. 
(3/8) 1 <= A <= N <= 5000, 1 <= M <= 50000, 1 <= K <= 100, all children are different agesand the age sequence is incremented.
(1/8) 1 <= A <= N <= 5000, 1 <= M <= 50000, 1 <= K <= 100, 
(1/8) 1 <= A <= N <= 500000, 1 <= M, K <= 2000.

Output

The output contains one line.

Output the age sequence of the children in clockwise from the youngest.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13442.c

Partial Judge Header

13442.h

Tags

The output contains 11111111111111111111



Discuss




13825 - The Last of DYY's Hamon   

Description

 

"Oh no! The power is off again!" Says a student playing games in the dorm.

"This is the last of my Hamon!" -DYY.

Our greatest ​vice president for general affairs is trying to resolve the power outage problem by the end of his term. In the beginning, He's trying to ask Doraemon for help. Unfortunately, Doraemon already retired last semester! In turn, he seeks cheap labor, the Pokemon Pikachu to do him a favor. By using Pikachu's move "10 万ボルト (Thunderbolt)", the campus would generate enough electricity, and can be lit up forever! This is too trivial for him...How clever is DYY!

The main power pipe of the campus is connecting the substation in a line, each substation has a id number representing it. Now, DYY wants to rearrange the order of the substations, by reversing the segments on the power pipe. Help him!


This is a partial judge problem. For the given linked list, you would only need to implement the function "reverse" to do the corresponding operation. For your convenience, we already pass the pointer of node_l and node_r to the function. You can refer to the following image to know the detail. If you implement the function and reverse the linked list correctly, the given program would output two lines - the reversed linked list and "pikachuuuu!!", and you can pass this problem.

 

 

Input

  • The first line contains two integers N and Q (1 < N, Q ≤ 100) - the number of substations and the number of the operation instructed by DYY
  • The second line contains N integers x1, x2, ..., xn (1 <= xi <= 109) - the id of each substation
  • Each of the next Q lines contains three integers l and r (1 < l ≤ r ≤ N) - reverse the l-th to r-th substations

 

Output

If you implement the function and reverse the linked list correctly, the given program would output two lines - the reversed linked list and "pikachuuuu!!", and you can pass this problem.

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

13825.c

Partial Judge Header

13825.h

Tags




Discuss