QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#4291. 条形分类

統計

你在大学里修读机器学习课程,家庭作业要求你编写一个程序,能够识别图像中的垂直条和水平条。为了生成一些训练数据,你使用了以下方法:首先,取一个 $N \times N$ 的网格,并将其全部填满零。接着,选取一行或一列,将其全部填满一。最后,选取至多 $N$ 个任意单元格进行翻转。翻转一个单元格意味着将零变为一,或将一变为零。

用这种方法生成数据很容易,但如何生成所有的答案呢?手动处理这些训练数据需要花费数小时。如果你能有一个自动找出所有输出的程序就好了。

给定一个按照上述描述生成的 $N \times N$ 矩阵,请编写一个程序,判断最初被填满一的是列还是行,或者判断是否无法确定。

输入格式

第一行包含一个整数 $N$ ($2 \le N \le 1000$),表示网格的大小。 接下来的 $N$ 行,每行包含一个长度为 $N$ 的由零和一组成的字符串。这些是网格的行。

题目保证输入数据是通过以下方式生成的:取一个全零网格,将某一行或某一列填满一,然后翻转至多 $N$ 个单元格。

输出格式

如果条形是垂直的(列),输出 “|”。如果条形是水平的(行),输出 “-”。如果无法确定(因为两者皆有可能),输出 “+”。

样例

样例输入 1

5
01100
01000
01001
00000
01000

样例输出 1

|

样例输入 2

3
111
000
111

样例输出 2

-

样例输入 3

3
010
101
010

样例输出 3

+

Figure 1. Illustration of the grid generation process described in the problem.

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.