1771 - I2P(I)2019_Hu_hw4 Scoreboard

Time

2019/10/07 20:30:00 2019/10/14 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10389 Text Editor
12419 Max Sum of Inversions
12420 Find The Ball!

10389 - Text Editor   

Description

In this problem we simulate a simple text editor. Given a series of keyboard input, output the final text content.
The text editing rules are defined as following:
1. Normal alphabetical input and whitespace input (abcdefg…. and ‘ ‘) directly write  after the cursor of the text content.
And four special commands started with a backslash(/) character
2. The backspace command which deletes a letter before the cursor (/backspace)
3. The newline command which creates a new line after the cursor (/newline)
4. The two navigating commands which move the cursor (/left /right)

The size of the text content is fixed to 500 characters, and the text content of testcases will not exceed 500 characters when simulating.

Hint:

#include 

#define MAX_SIZE 500

char content[MAX_SIZE];
char input[MAX_SIZE];

int main()
{

    fgets(input, MAX_SIZE, stdin);

    /* your code here */

    printf("%s", content);

    return 0;
}

Input

The keyboard input sequence.
There is always a valid command(/backspace /newline /left /right) right after the backslash character.
There is no newline character at the end

Output

The final text content.
 

Sample Input  Download

Sample Output  Download

Tags




Discuss




12419 - Max Sum of Inversions   

Description

One day, your mathematician friend get trouble again. He is trying to find the max sum of the inversion in the array, but the array is too large to calculate by handcraft method. He ask you to help him finish the job and write down the problem below:

Inversion : Let S be a sequence if i < j and S(i) > S(j), either the pair of places (i,j) or the pair of elemets (S(i),S(j)) is called an inversion of S. Take [1,2,3,6,5,4] for example. (6,5) , (6,4) , (5,4) are inversion of the sequence [1,2,3,4,5,6]

Max sum of inversion: Calculate the sum of each inversion and find out the max sum. Take previous result (6,5), (6,4), (5,4) for example. Each sum of inversion will be 11, 10 and 9, then 11 is the max sum of inversion.

Input

T

N_1 S_1

N_2 S_2

...

N_T S_T

T : The number of the testcase (1<= T<= 10)

N_i : The size of input sequence (2<= N_i < 1000)

S_i : The positive sequence with each element in the sequence is less than 1000000

Output

If there exists inversions, print out the max sum of inversions in the sequence

If there doesn't exists inversions, print out the string "No Inversion!"

(each output string must follow by a newline character)

Sample Input  Download

Sample Output  Download

Tags




Discuss




12420 - Find The Ball!   

Description

Find the ball is one of the most interesting game in the past. Playing "Find the ball" will test and improve the player's attention and memory. In the begining of the game, There are one yellow ball will be hidden under three cups and then swaps each cup many time as fast as possible, Finally, you need to find where is the ball.

One day, a game developer thinked that using three cups to play the game is too easy. He wanted to expaned three cups to n cups and one ball to m ball. However he was no idea to write an program for the game. In order to help the game developer, you need to write a program to simulate the procedure and record the final location of each ball.

Input

N

M S

T

A_1 B_1

A_2 B_2

N : The size of cups (3 <= N <= 40)

M : The number of balls (1<= B <= N/2, and each location of ball will not repeat)

S : The sequence of each ball's location

T : The number of instruction to swap the cup (1 <= T < 100)

A_i, B_i : The location of both two cup to swap (A_i and B_i may have same value)

Note: the location start from 1

Output

Print out the simulated procedure and the final location of each ball from left to right.

(for simulated procedure : each line followed by a newline).

(Balls are represented by asterisk '*', and non-ball cells are represented by a minus sign '-')

(for the final location of each ball : each location should be separated by a space, and make sure there is a trailing space followed by a newline character at the end of line.)

Note: for simulated procedure should print out the initial state first

Sample Input  Download

Sample Output  Download

Tags




Discuss