问题1811--simple problem

1811: simple problem

时间限制: 1 Sec  内存限制: 128 MB
提交: 22  解决: 5
[状态] [讨论版] [提交] [命题人:]
题目描述

In chess, the player who moves first is referred to as "White" and the player who moves second is referred to as "Black". Similarly, the pieces that each conducts are called, respectively, "the white pieces" and "the black pieces". The pieces are often not literally white and black, but some other colors (usually a light color and a dark color, respectively). The 64 squares of the chessboard, which is colored in a checkered pattern, are likewise referred to as "white squares" or "light squares" on the one hand, and "black squares" or "dark squares" on the other. In most cases, the squares are not actually white and black, but a light color and a contrasting dark color. For example, the squares on plastic boards are often off-white ("buff") and green, while those on wood boards are often light brown and dark brown.

 

Reversi is a strategy board game for two players, played on an 8×8 uncheckered board. There are sixty-four identical game pieces called disks (often spelled "discs"), which are light on one side and dark on the other. Players take turns placing disks on the board with their assigned color facing up. During a play, any disks of the opponent's color that are in a straight line and bounded by the disk just placed and another disk of the current player's color are turned over to the current player's color.

The object of the game is to have the majority of disks turned to display your color when the last playable empty square is filled.

 

Now, we simplify this rule, only give you a legal state when it's white turns,and judge whether the white party will win.

 

Spy likes to play Reversi before,but he's very stupid, always lose.Can you help him?

输入

The first line of the input contains two integers n(2<=n<=20),m(2<=m<=20,n<=m).Next 2~n+1 lines,each line contains a pair of space-separated positive integers x, y(1<=x, y<=8),represents the position of the white.Next n+2~n+m+1 lines,each line contains a pair of space-separated positive integers x, y(1<=x, y<=8),represents the position of the black.

输出

In the first line print "YES" (without the quotes),if white win(the number of white pieces more than the number of black pieces), and the second line print the number that white pieces more than black pieces as much as possible.

If white can't win, print in a single line "NO" (without the quotes).

样例输入 Copy
1 2
1 4
1 2
1 3
样例输出 Copy
YES
4