F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Let’s play chess

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1    Accepted Submission(s): 1


Problem Description
Reversi is a strategy board game for two players, played on an 8×8 board. There are 64 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?
 

Input
The input contains multiple test cases. For each case:
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.
 

Output
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).
 

Sample Input
1 2 1 4 1 2 1 3
 

Sample Output
YES 4
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-29 18:20:49, Gzip enabled