Processing math: 100%
Bit reversing - MarisaOJ: Marisa Online Judge

Bit reversing

Time limit: 1000 ms
Memory limit: 256 MB
Given a binary matrix A of n rows and m columns. You can do the following operation on the matrix: - Select a row or a column and reverse every numbers on that row or column (.i.e 1 turn into 0, and 0 turn into 1). You are given q queries of form (a,b,c,d). Determine if the submatrix with upper-left corner at (a,b) and lower-right corner at (c,d) can be transformed into a matrix full of 0 by applying the above operation? ### Input - The first line contains 3 integers n,m,q. - The next n lines, each line contains a binary string of length m. - The next q lines, each line contains 4 integers a,b,c,d, a query. ### Output - For each query, print YES if the submatrix can be transformed into a matrix full of 0, otherwise print NO. ### Constraints - 1≤n,m≤500. - 1≤q≤105. - 1≤a,c≤n. - 1≤b,d≤m. ### Example Input: 333101001110213222331123 Output: YESYESNO