QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#18486. 抗體辨識

统计

VUNO 是一家專業的醫療 AI 解決方案開發企業,利用透過大數據與深度學習技術訓練的人工智慧,來協助醫學專家的決策。

VUNO 最近開發了一種名為 SP 的強大全新造影技術。使用此技術時,人體組織會被表示為網格結構,網格中的每個格子會被賦予一個壓縮了該部分各種分析結果的單一資料值。VUNO 計劃使用這種 SP 造影技術來研究一種名為 CPCU-1202 的新抗體。

當在組織中接種 CPCU-1202 疫苗時,會在網格的其中一個格子中產生抗體。如果與該抗體當前所在的格子具有相同資料值,且在上下左右方向上相鄰,抗體就會擴散到該格子。這個過程會不斷重複,直到抗體無法再繼續擴散為止,此時抗體便會完全滲透到組織中。結果,抗體擴散過的所有格子的資料值都會被更新為同一個新的數值。此時,更新後的資料值有可能剛好與原本的資料值相同。

VUNO 的研究數據由同一個組織在「接種疫苗前」與「接種疫苗後」的一對造影結果組成。給定兩張造影結果,請編寫一個程式,判斷該組織所接種的疫苗是否可能是 CPCU-1202 疫苗。

圖 B.1:CPCU-1202 疫苗接種過程

輸入格式

第一行包含兩個整數 $N$ 和 $M$ ($1 \le N, M \le 30$),表示 SP 造影結果的大小。這代表造影結果是一個高為 $N$ 格、寬為 $M$ 格的網格。

接下來的 $N$ 行給出接種疫苗前的造影結果。每行包含 $M$ 個以空格分隔的整數(介於 $1$ 到 $1000$ 之間),其中第 $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.