#P14901. [ICPC 2018 Yokohama R] Ranks

[ICPC 2018 Yokohama R] Ranks

题目描述

A finite field F2\mathbf{F}_2 consists of two elements: 00 and 11. Addition and multiplication on F2\mathbf{F}_2 are those on integers modulo two, as defined below.

+\boldsymbol{+} 0\mathbf{0} 1\mathbf{1}
0\mathbf{0}
1\mathbf{1} 0\mathbf{0}
×\boldsymbol{\times} 0\mathbf{0} 1\mathbf{1}
0\mathbf{0} 0\mathbf{0}
1\mathbf{1} 1\mathbf{1}

A set of vectors v1,,vk\mathbf{v}_1, \ldots, \mathbf{v}_k over F2\mathbf{F}_2 with the same dimension is said to be linearly independent when, for c1,,ckF2c_1, \ldots, c_k \in \mathbf{F}_2, $c_1 \mathbf{v}_1 + \cdots + c_k \mathbf{v}_k = \mathbf{0}$ is equivalent to c1==ck=0c_1 = \cdots = c_k = 0, where 0\mathbf{0} is the zero vector, the vector with all its elements being zero.

The rank of a matrix is the maximum cardinality of its linearly independent sets of column vectors. For example, the rank of the matrix $\begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 1 \end{bmatrix}$ is two; the column vectors [01]\begin{bmatrix} 0 \\ 1 \end{bmatrix} and [11]\begin{bmatrix} 1 \\ 1 \end{bmatrix} (the first and the third columns) are linearly independent while the set of all three column vectors is not linearly independent. Note that the rank is zero for the zero matrix.

Given the above definition of the rank of matrices, the following may be an intriguing question. How does a modification of an entry in a matrix change the rank of the matrix? To investigate this question, let us suppose that we are given a matrix AA over F2\mathbf{F}_2. For any indices ii and jj, let A(ij)A^{(ij)} be a matrix equivalent to AA except that the (i,j)(i,j) entry is flipped.

$$A^{(ij)}_{kl} = \begin{cases} A_{kl} + 1 & (k = i \text{ and } l = j) \\ A_{kl} & (\text{otherwise}) \end{cases}$$

In this problem, we are interested in the rank of the matrix A(ij)A^{(ij)}. Let us denote the rank of AA by rr, and that of A(ij)A^{(ij)} by r(ij)r^{(ij)}. Your task is to determine, for all (i,j)(i,j) entries, the relation of ranks before and after flipping the entry out of the following possibilities: (i) r(ij)<rr^{(ij)} < r, (ii) r(ij)=rr^{(ij)} = r, or (iii) r(ij)>rr^{(ij)} > r.

输入格式

The input consists of a single test case of the following format.

$$\begin{aligned} & n \; m \\ & A_{11} \ldots A_{1m} \\ & \vdots \\ & A_{n1} \ldots A_{nm} \end{aligned}$$

nn and mm are the numbers of rows and columns in the matrix AA, respectively (1n10001 \leq n \leq 1000, 1m10001 \leq m \leq 1000). In the next nn lines, the entries of AA are listed without spaces in between. AijA_{ij} is the entry in the ii-th row and jj-th column, which is either 00 or 11.

输出格式

Output nn lines, each consisting of mm characters. The character in the ii-th line at the jj-th position must be either - (minus), 00 (zero), or ++ (plus). They correspond to the possibilities (i), (ii), and (iii) in the problem statement respectively.

2 3
001
101
-0-
-00
5 4
1111
1000
1000
1000
1000
0000
0+++
0+++
0+++
0+++
10 10
1000001001
0000010100
0000100010
0001000001
0010000010
0100000100
1000001000
0000010000
0000100000
0001000001
000-00000-
0-00000-00
00-00000-0
+00000+000
00-0000000
0-00000000
000-00000-
0-000-0-00
00-0-000-0
+00000+000
1 1
0
+