TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Given $N \times M$ matrix $A$, a size $N$ vector $b$. Please calculate a (size $M$) vector $x$ s.t. $Ax = b$. We consider everything $\mathbb{F}_ {2}$.

For the input and output of matrices and vectors, please treat each row as a string concatenated with its components ($0$ or $1$).

Input Format

$N$ $M$
$A_ {0,0}A_ {0,1}\cdots A_ {0,M-1}$
$A_ {1,0}A_ {1,1}\cdots A_ {1,M-1}$
$\vdots$
$A_ {N-1,0}A_ {N-1,1}\cdots A_ {N-1,M-1}$
$b_ 0b_ 1\cdots b_ {N-1}$

Output Format

If there is no solution, print
-1

and if exists, print as follows.
$R$
$c_ 0c_ 1\cdots c_ {M-1}$
$d_ {0,0}d_ {0,1}\cdots d_ {0,M-1}$
$\vdots$
$d_ {R-1,0}d_ {R-1,1}\cdots d_ {R-1,M-1}$

We note that $R$ is the rank of solution. $c_ i$ is one of the solution. For each $j$, $d_ {j,0}\cdots d_ {j,M-1}$ is the basis of solution.

Sample Input 1

3 3
101
011
110
011

Sample Output 1

1
010
111

Sample Input 2

3 3
101
011
110
111

Sample Output 2

-1

Sample Input 3

1 3
111
1

Sample Output 3

2
100
110
101

Hints

  • $1 \leq N \leq 2^ {12}$
  • $1 \leq M \leq 2^ {12}$
  • $A_ {ij} \in \lbrace 0,1\rbrace$
  • $b_ {i} \in \lbrace 0,1\rbrace$

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 2097152 2097152
1 5000 2097152 2097152
2 5000 2097152 2097152
3 5000 2097152 2097152
4 5000 2097152 2097152
5 5000 2097152 2097152
6 5000 2097152 2097152
7 5000 2097152 2097152
8 5000 2097152 2097152
9 5000 2097152 2097152
10 5000 2097152 2097152
11 5000 2097152 2097152
12 5000 2097152 2097152
13 5000 2097152 2097152
14 5000 2097152 2097152
15 5000 2097152 2097152
16 5000 2097152 2097152
17 5000 2097152 2097152
18 5000 2097152 2097152
19 5000 2097152 2097152
20 5000 2097152 2097152
21 5000 2097152 2097152
22 5000 2097152 2097152
23 5000 2097152 2097152
24 5000 2097152 2097152
25 5000 2097152 2097152
26 5000 2097152 2097152
27 5000 2097152 2097152
28 5000 2097152 2097152
29 5000 2097152 2097152
30 5000 2097152 2097152
31 5000 2097152 2097152
32 5000 2097152 2097152
33 5000 2097152 2097152
34 5000 2097152 2097152
35 5000 2097152 2097152