2430 - I2P(I)2021_Hu_Hw9 Scoreboard

Time

2021/11/18 16:00:00 2021/11/29 18:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13361 Cardcaptor Sakura
13362 Gray code
13364 Mom, don't do that

13361 - Cardcaptor Sakura   

Description

Sakura is a girl with super card magic.

However, you cannot make a living with magic, computer science is all you need.

To make use of her card skills, she tries to write a program to play cards:

 

There are 10 tables (indexed from 0 to 9) and no cards on them initially.

Given a command S, Sakura has to follow the instructions below:

(1) print: print the status of each table with the format :"table_idx: cards_on_the tables\n", e.g. "0: 1 3 3 4 5\n"

Note that if there are no cards, print "No card".

(2) all num len :  Place len cards on each table, and the value on each card is num .

For example, the instruction "all 3 4" changes the status of each table to "table_idx: 3 3 3 3\n";

(3)

place table_idx len

integer_sequence

: Place a stack of cards on table table_idx. len means the number of cards in the stack. An integer sequence integer_sequence of length len is given, in which each integer means the value on the placed card.

For example, the instruction will be like:

place 2 3

3 2 1

And the status of Table_2 will become:

2: 3 2 1

Note that if there are cards already on the target table, the status will be overridden.

(4) swap table_a table_b: Swap the cards on table_a and table_b.

For example:

If the origin status of table 0 and table 1 are:

0: 1 2 3

1: 4 5 6

after "swap 0 1", the status of the two tables become:

0: 4 5 6

1: 1 2 3

This instruction is valid even if one of the tables is empty.

(5) clear: Clean all the tables.

(6) exit: terminates

 

hint. You can use pointer array to record each table.

Input

Commands separated by a newline character.

Note that:

1 <= the value of each card <= 13

1 <= number of cards on each table <= 10000

Output

Status of each table.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss




13362 - Gray code   

Description

An n-bit gray code sequence is a sequence of 2^n integers where:

  • Every integer is in the inclusive range [0, 2^n - 1],
  • The first integer is 0,
  • An integer appears no more than once in the sequence,
  • The binary representation of every pair of adjacent integers differs by exactly one bit, and
  • The binary representation of the first and last integers differs by exactly one bit.

For example, a if n = 2:

The binary representation of [0,1,3,2] is [00,01,11,10].
- 00 and 01 differ by one bit
- 01 and 11 differ by one bit
- 11 and 10 differ by one bit
- 10 and 00 differ by one bit

Given an integer n, print the gray code sequence.

Note that you have to follow the standard encoding since there are more than one sequences satisfy the requirements.

For example, if n = 4:

Reference:

https://en.wikipedia.org/wiki/Gray_code

Input

1<=n<=20

Output

The corresponding gray code sequence.

Note that you have to print "\n" after each numbers. 

Sample Input  Download

Sample Output  Download

Tags




Discuss




13364 - Mom, don't do that   

Description

"Mom, don't do that."

You have some secret folders which store a lot of videos about algorithm.

However, you do not want your mom know that you are interested in CS (she wants you to become a doctor).

Thus, you use a special trick to rearrange the original directory and sub-directory so it's difficult to directly access the folder.

Also, you make some fake directories, trying to make your mom more confused.

Although you think it's safe enough, your mom wrote a super program to check whether the decoded directory is valid or not.

Orz.

In order to figure out how your mom does that, you are going to design a similar program.

Given testcases T, each with two strings, O (origin directory) and (decoded directory), please print "valid" if you can rearrange D into a sub-directory of O; if it's not possible, print "not valid".

Next time, remember to lock your room before leaving home.

 

hint. You can use string.h to make the problem easier.

Input

The first line of the input is an intger T, denoting the number of testcases. 1<= T <= 100

Next 2*T lines contain information of T pairs of O and D.

is a directory, composed of a sequence of folders separated by a "/", e.g. "/home/hii/it/is/a/folder".

D is a decoded directory, which may be a sub-directory of O or an invalid directory:

example 1: "/hii/home/it", which is valid because you rearrange it into "/home/hii/it".

example 2: "/hii/it/home/nooo", which is invalid because "nooo" is not a part of folders of O.

1 <= length of O or D <= 5000

1 <= number of folders in O <= 50

Note that O and D must start from a "/", and there is no "/" in the end and each folder may appear more than once.

 

Output

For each testcases, if D may be valid, print "valid".

Otherwise, print "not valid".

Note that you have to print "\n" after each answer.

Sample Input  Download

Sample Output  Download

Tags




Discuss