QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#3319. 排名

Statistiques

有限域 $\mathbf{F}_2$ 由两个元素 0 和 1 组成。$\mathbf{F}_2$ 上的加法和乘法是整数模二运算,定义如下:

$+$ 0 1
0 0 1
1 1 0
$\times$ 0 1
0 0 0
1 0 1

若对于 $c_1, \dots, c_k \in \mathbf{F}_2$,等式 $c_1\mathbf{v}_1 + \dots + c_k\mathbf{v}_k = \mathbf{0}$ 成立当且仅当 $c_1 = \dots = c_k = 0$(其中 $\mathbf{0}$ 为零向量,即所有元素均为 0 的向量),则称 $\mathbf{F}_2$ 上的一组同维向量 $\mathbf{v}_1, \dots, \mathbf{v}_k$ 是线性无关的。

矩阵的秩是其列向量组中线性无关子集的最大基数。例如,矩阵 $\begin{bmatrix} 0 & 0 & 1 \\ 1 & 0 & 1 \end{bmatrix}$ 的秩为 2;列向量 $\begin{bmatrix} 0 \\ 1 \end{bmatrix}$ 和 $\begin{bmatrix} 1 \\ 1 \end{bmatrix}$(第一列和第三列)是线性无关的,而所有三列组成的集合不是线性无关的。注意零矩阵的秩为零。

给定上述矩阵秩的定义,以下可能是一个有趣的问题:修改矩阵中的一个元素如何改变矩阵的秩?为了研究这个问题,假设我们给定一个 $\mathbf{F}_2$ 上的矩阵 $A$。对于任意索引 $i$ 和 $j$,令 $A^{(ij)}$ 为除 $(i, j)$ 位置的元素被翻转外与 $A$ 等价的矩阵。

$$ A^{(ij)}_{kl} = \begin{cases} A_{kl} + 1 & (k = i \text{ 且 } l = j) \\ A_{kl} & (\text{其他情况}) \end{cases} $$

在本题中,我们关注矩阵 $A^{(ij)}$ 的秩。设 $A$ 的秩为 $r$,而 $A^{(ij)}$ 的秩为 $r^{(ij)}$。你的任务是对于所有 $(i, j)$ 位置,确定翻转元素前后秩的关系,即以下三种可能性之一:(i) $r^{(ij)} < r$,(ii) $r^{(ij)} = r$,或 (iii) $r^{(ij)} > r$。

输入格式

输入包含单个测试用例,格式如下:

$n$ $m$ $A_{11} \dots A_{1m}$ $\vdots$ $A_{n1} \dots A_{nm}$

$n$ 和 $m$ 分别是矩阵 $A$ 的行数和列数($1 \le n \le 1000$,$1 \le m \le 1000$)。接下来的 $n$ 行中,列出了 $A$ 的元素,中间没有空格。$A_{ij}$ 是第 $i$ 行第 $j$ 列的元素,为 0 或 1。

输出格式

输出 $n$ 行,每行包含 $m$ 个字符。第 $i$ 行第 $j$ 个位置的字符必须是 -(减号)、0(零)或 +(加号)。它们分别对应题目描述中的可能性 (i)、(ii) 和 (iii)。

样例

样例输入 1

2 3
001
101

样例输出 1

-0-
-00

样例输入 2

5 4
1111
1000
1000
1000
1000

样例输出 2

0000
0+++
0+++
0+++
0+++

样例输入 3

10 10
1000001001
0000010100
0000100010
0001000001
0010000010
0100000100
1000001000
0000010000
0000100000
0001000001

样例输出 3

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

样例输入 4

1 1
0

样例输出 4

+

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.