QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#18486. 抗体認識

統計

VUNOは、ビッグデータとディープラーニング技術を通じて学習した人工知能を利用し、医療専門家の判断を支援するMedical AIソリューションを開発する専門企業である。

VUNOは最近、SPという強力な新しい撮影技術を開発した。この技術を使用すると、人体組織が格子状に表現され、格子の各マスには該当部分の各種分析結果を圧縮した1つのデータ値が与えられる。VUNOはこのSP撮影技術を使用して、CPCU-1202という新しい抗体を研究しようとしている。

組織にCPCU-1202ワクチンを接種すると、格子のマスのうちの1つに抗体が生成される。この抗体は、現在属しているマスと同じデータ値を持ち、上下左右に隣接するマスがある場合、そのマスへと広がっていく。このプロセスを繰り返し、抗体がそれ以上広がることができなくなると、抗体は組織に完全に浸透する。その結果として、抗体が広がったマス目のデータ値はすべて、ある同一の新しい値に更新される。このとき、偶然にも元のデータ値と更新後のデータ値が同じになることもある。

VUNOの研究データは、1つの組織に対してワクチンを接種する前の撮影結果と、ワクチンを接種した後の撮影結果がペアになっている。2枚の撮影結果が与えられたとき、この組織に接種したワクチンがCPCU-1202ワクチンである可能性があるかどうかを判定するプログラムを作成せよ。

図 B.1: CPCU-1202 ワクチン接種プロセス

入力

最初の行には、SP撮影結果のサイズを表す2つの整数 $N$ と $M$ が与えられる。($1 \le N, M \le 30$) これは、撮影結果が縦 $N$ マス、横 $M$ マスの大きさの格子であることを意味する。

続く $N$ 行には、ワクチンを接種する前の撮影結果が与えられる。各行には $1$ 以上 $1\,000$ 以下の整数 $M$ 個が空白で区切られて与えられ、$i$ 番目の行の $j$ 番目の数値は、撮影結果の $i$ 行目 $j$ 列目のマスのデータ値を意味する。

続く $N$ 行には、ワクチンを接種した後の撮影結果が上記と同様の形式で与えられる。

出力

撮影対象に接種されたワクチンがCPCU-1202ワクチンである可能性がある場合は YES を、そうでない場合は NO を出力せよ。

入出力例

入力 1

4 4
2 2 2 1
2 2 1 3
2 1 3 3
1 3 3 3
4 4 4 1
4 4 1 3
4 1 3 3
1 3 3 3

出力 1

YES

入力 2

4 4
2 2 2 1
2 2 1 3
2 1 3 3
1 3 3 3
2 2 2 1
2 2 1 3
2 1 3 3
1 3 3 3

出力 2

YES

入力 3

4 4
2 2 2 1
2 2 1 3
2 1 3 3
1 3 3 3
2 2 2 1
2 2 2 3
2 1 3 3
1 3 3 3

出力 3

YES

入力 4

4 4
2 2 2 1
2 2 1 2
2 1 2 2
1 2 2 2
3 3 3 1
3 3 1 3
3 1 3 3
1 3 3 3

出力 4

NO

入力 5

3 5
1 1 1 3 3
1 1 2 3 3
1 1 2 2 4
1 1 1 4 4
1 1 2 4 4
1 1 2 2 4

出力 5

YES

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.