Cross Xor solution codeforces
There is a grid withrows and columns, where the square on the -th row and -th column has an integer written on it. Initially, all elements are set to . We are allowed to do the following operation:
- Choose indices and , then replace all values on the same row or column as with the value xor . In other words, for all where or or both, replace with xor .
You want to form grid ?‘ instead.by doing the above operations a finite number of times. However, some elements of are missing and are replaced with ‘
Let ?‘ characters. Among all the ways of filling up the grid by replacing each ‘?‘ with ‘‘ or ‘1‘, count the number of grids, that can be formed by doing the above operation a finite number of times, starting from the grid filled with . As this number can be large, output it modulo .be the number of ‘
The first line contains two integersand ( ) — the number of rows and columns of the grid respectively.
The-th of the next lines contain characters ( ).
Print a single integer representing the number of ways to fill up gridmodulo .
3 3 ?10 1?? 010
2 3 000 001
1 1 ?
6 9 1101011?0 001101?00 101000110 001011010 0101?01?? 00?1000?0
In the first test case, the only way to fill in thes is to fill it in as such:
In the second test case, it can be shown that there is no sequence of operations that can produce that grid.
I am the Founder and the creator of the blog neoideasblog.com where we share latest trivia questions and answers on a daily basis.