No.819 Enjapma game
タグ : / 解いたユーザー数 40
作問者 :
Enjapma_kyopro
/ テスター :
omochana2
Problem Statement
In recognition of your achievements in solving numerous difficult problems, you have at last been given the chance to become the king of this country.
The condition is to face King Enjapma directly in a game and win. The rules of the game are as follows.
$1$ . There is a grid with $H$ rows and $W$ columns, and some of the cells each have $1$ piece placed on them.
The $j$-th character of the given string $S_i$ represents the state of the cell in the $i$-th row from the top and the $j$-th column from the left. The character o means that a piece is placed there, and - means that no piece is placed there.
$2$ . King Enjapma moves first, and the two players take turns alternately.
$3$ . On a turn, a player chooses whichever they like of the following $2$ operations.
・Choose $1$ piece and move it to the cell $1$ below it or to the left of it. However, the destination cell must not contain a piece.
・Choose $1$ piece and remove it from the board.
$4$ . The player who cannot take a turn because no pieces remain on the board loses.
If both players play optimally, can you become the king? In other words, can you win this game?
Input
$H$ $W$ $S_1$ $S_2$ : $S_H$
$1 \le H \le 200$
$1 \le W \le 200$
$| S_i | = W$
Each character of $S$ is either o or -.
Output
Print YES if you can win, and NO if you cannot.
Print a newline at the end.
Sample
Sample 1
Input
3 3
---
-o-
-o-
Output
YES
If the king removes a piece, you should also remove a piece.
If the king moves a piece to the left, you should also move a piece. In this case, on the next turn the king has no choice but to remove a piece, and you should also remove a piece.
Sample 2
Input
2 3
o-o
o--
Output
NO
No matter how you act, you cannot win.
Sample 3
Input
5 49
-ooooo--o---o---oooo----o----oooo---o---o----o---
-o------oo--o-----o----o-o---o---o--oo-oo---o-o--
-oooo---o-o-o-----o---o---o--oooo---o-o-o--o---o-
-o------o--oo--o--o---ooooo--o------o---o--ooooo-
-ooooo--o---o---oo----o---o--o------o---o--o---o-
Output
YES
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。