Xortris
Time limit1sMemory limit256 MB
Decide whether the black cells of a board of up to 100 by 100 cells can all be turned white by repeatedly flipping four cells covered by a tetromino.
- Level
Hard8 of 10
- Topics
- Math, Combinatorics
- Solved
- No attempts yet
Problem
It is 1990 and you work in the development team of a video game that will change arcades. The player gets a rectangular board of white and black squares. The goal is to turn the whole board white. On each turn the player may pick a tetromino from an infinite supply, move and rotate it so that the piece lies entirely inside the board, and flip the color of the four squares it covers. A tetromino is a set of four squares joined edge to edge into one connected piece (Figure 1).
The testing team keeps complaining that some levels cannot be solved at all. The testers are skilled enough to place a piece in any position and rotation they need, so the cause is somewhere else. Your next debugging step is to write a program that decides whether a level can be solved.

Figure 1: all tetrominoes. Source: Wikimedia.
Input
The first line contains two integers and (), the dimensions of the board. Then follow lines with characters each. The character . is a white square and the character X is a black square.
Output
Print one line with possible if the level can be solved and impossible if it cannot.