QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#18930. Yet Another Binary Problem

Statistics

01로만 이뤄진 $N\times M$ 크기의 격자 $A$가 주어진다. 당신은 아래 두 종류의 시행을 원하는 만큼 할 수 있다.

  1. 같은 행에 있는 두 수 0, 1을 하나씩 없앤다.

  2. 같은 열에 있는 두 수 0, 1을 하나씩 없앤다.

수가 없어진 칸은 빈 칸이 된다. 시행 횟수를 최대로 하는 방법을 하나 찾아보자.

입력

첫째 줄에 두 정수 $N$, $M$이 공백을 사이에 두고 주어진다. ($1\le N,M\le 5000$)

다음 $N$줄에 걸쳐 $i+1$번째 줄에 격자 $A$를 나타내는 $M$개의 수 $A_{i1},A_{i2},\ldots,A_{iM}$가 공백 없이 주어진다. $A_{ij}$는 격자의 $i$행 $j$열에 적힌 수를 나타낸다. ($0\le A_{ij}\le 1$)

출력

$N$줄에 걸쳐 각 수가 어떤 시행에 의해 없어졌는지 나타내는 $M$개의 문자 $B_{i1},B_{i2},\ldots,B_{iM}$를 공백 없이 출력한다. 이때 $i$행 $j$열의 수가 $1$번 시행에 의해 없어진 경우 $B_{ij}=1$, $2$번 시행에 의해 없어진 경우 $B_{ij}=2$, 없어지지 않은 경우 $B_{ij}=\mathtt{x}$로 한다.

입출력 예시

예시 1

입력

3 4
0111
1001
1000

출력

1212
1111
1212

예시 2

입력

2 2
00
10

출력

2x
2x

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.