E: Minesweeper

January 24th, 2010 | Categories: 2009 Regionals

It’s just Minesweeper. Everyone knows Minesweeper. This problem was solved by more teams than any other.

Check out the Judge Input, the Judge Output, the main Solving Program, another solution, and another. There are also C++ solutions here and here.

[spoiler]
The algorithm is obvious – just do what the problem says. For every non-mine cell, look at the (up to) 8 cells around, and count the number of mines. So, the key to solving this problem is just to be careful about certain things.

  • Don’t go off the edge of the board when you’re checking edge cells and corner cells
  • For some, correctly convert an integer to a char (others just printed the int directly). In both C++ and Java, this will work: ch = (char)(x+’0′)
  • Make sure your output spacing is correct.

[/spoiler]

No comments yet.
You must be logged in to post a comment.