MWC '15 #1 P2: Postcard

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Salarios77 wants to send a postcard to atarw but mailing is expensive. He notices that a good portion of a grid is just white paper, so output the smallest rectangular design that will encompass all of the black ink!

Input Specification

The first line will contain integers N (rows), M (columns) (separated by space).

Subtask 1 [10%]

2 \le N, M \le 5

Subtask 2 [10%]

2 \le N, M \le 100

Subtask 3 [80%]

2 \le N, M \le 1000

The following line will contain the design, with . representing white space and * being black (separated by spaces).

Note: Fast input may be required.

Output Specification

Output the grid in its smallest form.

Sample Input

4 4
. * * .
. . . .
. . . .
. * * .

Sample Output

* *
. .
. .
* *

Comments


  • -1
    bobhob314  commented on March 20, 2016, 4:30 p.m.

    Batch 3, Case 3 may have irregular spacing.


    • -1
      MathBunny123  commented on March 20, 2016, 5:32 p.m.

      We checked the data file and it appears to be fine. Do you have any specific detail we should check? We used the same generator for all cases so if it were to be an issue I'd believe it would happen across all cases. Thanks for the notice though!


  • 0
    CursedBlackCat  commented on March 19, 2016, 4:43 p.m. edited

    Do all of the test cases have 4 black ink dots? Or do some of them have more than four *?


    • 0
      MathBunny123  commented on March 19, 2016, 5:10 p.m.

      The number of black ink dots can be from 0 ≤ x ≤ NM