MWC '15 #1 P2: Postcard

View as PDF

Submit solution


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

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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, 12:30 p.m.

    Batch 3, Case 3 may have irregular spacing.


    • 0
      MathBunny123  commented on March 20, 2016, 1: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!


  • -1
    ramjet_engine  commented on March 19, 2016, 3:35 p.m.

    Why are the problems worth 100 or 300 points? What does this translate into in DMOJ's main points system?


    • -1
      Hypnova  commented on March 19, 2016, 4:18 p.m.

      No, its just point value within the contest, so for example, if someone solve P4, one of the harder problems, it is worth more than if someone solves P1.


  • -1
    CursedBlackCat  commented on March 19, 2016, 12: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, 1:10 p.m.

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