QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#10520. 行列除法

Statistics

$n \times m$ の 01 行列 $A$ と $m \times p$ の 01 行列 $B$ に対して、それらの積を $n \times p$ の 01 行列 $C$ と定義する。ここで、$C_{i,j} = \bigoplus_{k=1}^{m} A_{i,k} \& B_{k,j}$ である $^\dagger$。

現在、Link は乗法の逆演算である「除法」を行いたいと考えている。$n \times m$ の 01 行列 $A$ と $n \times p$ の 01 行列 $C$ が与えられたとき、$A$ と $B$ の積がちょうど $C$ に等しくなるような $m \times p$ の行列 $B$ を求める必要がある。

$^\dagger$ $\oplus$ はビット単位の XOR 演算を表し、$\&$ はビット単位の AND 演算を表す。例えば、$(0011)_2 \oplus (0101)_2 = (0110)_2$、$(0011)_2 \& (0101)_2 = (0001)_2$ である。

入力

各テストファイルにはテストデータが1つだけ含まれる。

第一行に3つの整数 $n, m, p$ ($1 \le n, m, p \le 1000$) が与えられる。

続く $n$ 行には、行列 $A$ の要素を表す $m$ 個の整数 $A_{i,1}, A_{i,2}, \dots, A_{i,m}$ ($A_{i,j} \in \{0, 1\}$) が各行に与えられる。

続く $n$ 行には、行列 $C$ の要素を表す $p$ 個の整数 $C_{i,1}, C_{i,2}, \dots, C_{i,p}$ ($C_{i,j} \in \{0, 1\}$) が各行に与えられる。

出力

条件を満たす行列 $B$ が存在しない場合は、「No」と出力せよ。

条件を満たす行列 $B$ が存在する場合は、1行目に「Yes」と出力し、続く $m$ 行に、見つけた行列 $B$ の要素である $p$ 個の整数 $B_{i,1}, B_{i,2}, \dots, B_{i,p}$ ($B_{i,j} \in \{0, 1\}$) を各行に出力せよ。

条件を満たす行列 $B$ が複数存在する場合は、そのうちのどれを出力してもよい。

入出力例

入出力例 1

3 2 3
1 0
1 1
1 0
0 0 0
0 1 0
0 0 0
Yes
0 0 0
0 1 0

入出力例 2

3 2 3
1 0
1 1
1 0
1 0 0
0 1 0
0 0 1
No

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.