Symmetric Matrix


Submit solution

Points: 20
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

題目說明

給定一個 N * N的整數矩陣,請判斷其對稱特性。
若矩陣中包含任何負整數,請輸出 Invalid。
若矩陣元素皆為非負整數,請根據以下定義輸出最精確的分類:

  • Invalid: 矩陣中包含負整數
  • Both: 同時符合Centrally-Symmetric與Horizontal-Mirror。
  • Centrally-Symmetric: 僅符合旋轉 180 度對稱\((M_{i,j}=M_{N-1-i},_{N-1-j})\)
  • Horizontal-Mirror: 僅符合水平中線翻轉對稱\((M_{i,j}=M_{N-1-i,j})\)
  • None: 以上皆不符合

輸入

由鍵盤輸入陣列大小整數N (0 < N <= 100)
N列N個填滿陣列的整數

輸出

對稱特性分類

樣本測資

輸入 輸出 說明
DataSet1 4
1 2 2 1
3 4 4 3
3 4 4 3
1 2 2 1
Both 旋轉 180 度相同,且上下翻轉也相同。
DataSet2 2
1 2
2 1
Centrally-Symmetric 僅 180 度對稱
DataSet3 3
1 2 3
0 0 0
1 2 3
Horizontal-Mirror 上下翻轉相同
DataSet4 2
1 2
3 4
None 無對稱
DataSet5 2
-5 0
 0 5
Invalid 包含負整數

Comments

There are no comments at the moment.