Array transformation - MarisaOJ: Marisa Online Judge

Array transformation

Time limit: 1000 ms
Memory limit: 256 MB
You are given two binary arrays, $A$ and $B$, both of size $n \times n$. Your task is to transform array $A$ into array $B$ using a series of operations. Each operation involves either flipping all the bits in a row or flipping all the bits in a column of array $A$. It is guaranteed that the answer exists. ### Input - The first line contains an integer $n$. - The next $n$ lines contain a binary string of length $n$, representing the rows of array $A$. - The next $n$ lines contain a binary string of length $n$, representing the rows of array $A$. ### Output - The first line should contain an integer $k$, representing the number of operations required. $k$ cannot exceed $10^6$. - The next $k$ lines should each contain an operation in the format `1 r` or `2 c`, indicating a row flip or column flip, respectively. ### Constraints - $1 \le n \le 1000$. ### Example Input: ``` 2 10 10 00 11 ``` Output: ``` 2 1 1 2 2 ```
Topic
Graph
Greedy
DSU
Rating 1600
Solution (0) Solution