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

Matrix Game

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


Problem Description
At the start of the matrix game, we have an n * m chessboard in which each grid is painted alternatively in white or black. Every time, we can apply one of the two following operations:
Row flip operation: we can change the color of every grid in a single row.
Column swap operation: we can swap two columns (i.e., switch the colors between corresponding grids).
The task of the problem is, determine whether it¡¯s possible to reach the target from the original chessboard by applying the two operations several times. Print ¡®Yes¡¯ or ¡®No¡¯ for each case.
 

Input
There are several test cases. For each case, there are two integers n and m in the first line (1 ¡Ü n, m ¡Ü 100), followed by two n * m 0/1 matrixes (0 stands for white color and 1 stands for black color) which are the original chessboard and the target chessboard respectively.
The input ends up with two negative numbers, which should not be processed as a case.
 

Output
For each test case, print ¡®Yes¡¯ or ¡®No¡¯ to tell whether it¡¯s possible to reach the target.
 

Sample Input
2 2 1 1 1 0 0 0 0 1 2 2 1 1 1 0 0 0 0 0 -1 -1
 

Sample Output
Yes No
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 12:19:54, Gzip enabled