2305 - DS_21_CHEN_HW2 (EECS2040) Scoreboard

Time

2021/04/15 09:00:00 2021/04/26 12:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13167 Did you just attack my village?

13167 - Did you just attack my village?   

Description

##TestCase 7 had been updated !!! (4/15)

Jennifer is a girl who loves to play Coin Master. One day, she angrily ran to the supermarket and shouted at the clerk Shirley, “Did you just attack my village?” Jennifer wants to detect the locations of the remaining houses in her village after being attacked. There are four types of instructions in this game, described as follows.

 

House: Jennifer can insert a house by using “House x y”. For example: Using “House 9 7” means Jennifer insert a house at (9,7).

Bomb: Shirley can attack Jennifer’s village by using “Bomb x y”. The houses located at ( x , y ), ( x+1 , y ), ( x-1, y ), ( x , y+1 ), ( x , y-1 ) will be vanished.

PrintFront: Print out the houses’ locations in Jennifer’s village from left to right and then bottom to top  (i,e, Lexicographic order)

PrintEnd: Print out the houses’ locations in Jennifer’s village from right to left and then top to bottom (i.e. reverse Lexicographic order)

 

Here is the demo animation of the sample input.

Input

The first line contains an integer N, representing the number of instructions

The following N lines represent the order of the instruction and coordinate position.

Each line starts with a string si, representing the type of instruction. si will be one of the following strings: House, Bomb, PrintFront, or PrintEnd.

If si is House or Bomb, si is followed by two integers x and y, representing x coordinate and y coordinate. 

If si is PrintFront or PrintEnd, there will be no more following input in the same line.

 

It is guaranteed that:

Test case #1~#7: N ≤ 50,   -1010 < x, y < 1010

Test case #8~#9: N ≤ 1000,  -1010 < x, y < 1010

Test case #10: N ≤ 5000,  -1010x, y < 1010

Output

For each instruction, you need to output the answer with the following format.

If the instruction is House or Bomb, you do not need to output anything.

If the instruction is PrintFront, print the text “PrintFrontfirst, and then print out the house locations in Jennifer’s village from left to right and then bottom to top (Notice: Each location will be printed in one line with the form of “(x,y)”. For example, you’ll print out 3 lines if there’re two locations - one for “PrintFront”, two for the locations). If there is no house in the village, just print "PrintFront".

If the instruction is PrintEnd, print the text “PrintEndfirst, and then print out the house locations in Jennifer’s village from right to left and then top to bottom (Notice: Each location will be printed in one line with the form of “(x,y)”. For example, you’ll print out 3 lines if there’re two locations - one for “PrintEnd”, two for the locations). If there is no house in the village, just print "PrintEnd".

Sample Input  Download

Sample Output  Download

Tags




Discuss