結果

問題 No.452 横着者のビンゴゲーム
ユーザー t8m8⛄️t8m8⛄️
提出日時 2016-12-03 16:13:17
言語 Nim
(2.0.2)
結果
AC  
実行時間 2,946 ms / 3,000 ms
コード長 3,063 bytes
コンパイル時間 3,890 ms
コンパイル使用メモリ 68,912 KB
実行使用メモリ 7,672 KB
最終ジャッジ日時 2023-09-12 08:06:18
合計ジャッジ時間 27,035 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,496 KB
testcase_03 AC 7 ms
5,012 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 8 ms
5,068 KB
testcase_06 AC 2 ms
4,744 KB
testcase_07 AC 4 ms
5,188 KB
testcase_08 AC 5 ms
5,028 KB
testcase_09 AC 2 ms
4,848 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 5 ms
5,008 KB
testcase_12 AC 4 ms
5,204 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2,946 ms
7,672 KB
testcase_15 AC 2,873 ms
7,540 KB
testcase_16 AC 1,551 ms
6,416 KB
testcase_17 AC 164 ms
5,084 KB
testcase_18 AC 125 ms
5,036 KB
testcase_19 AC 112 ms
5,000 KB
testcase_20 AC 111 ms
5,084 KB
testcase_21 AC 329 ms
5,132 KB
testcase_22 AC 111 ms
5,160 KB
testcase_23 AC 882 ms
6,260 KB
testcase_24 AC 114 ms
5,216 KB
testcase_25 AC 50 ms
5,056 KB
testcase_26 AC 339 ms
5,076 KB
testcase_27 AC 251 ms
5,056 KB
testcase_28 AC 141 ms
5,128 KB
testcase_29 AC 102 ms
5,072 KB
testcase_30 AC 424 ms
5,124 KB
testcase_31 AC 67 ms
5,208 KB
testcase_32 AC 63 ms
5,024 KB
testcase_33 AC 188 ms
5,056 KB
testcase_34 AC 151 ms
5,232 KB
testcase_35 AC 156 ms
5,040 KB
testcase_36 AC 63 ms
5,064 KB
testcase_37 AC 81 ms
5,164 KB
testcase_38 AC 1,817 ms
6,360 KB
testcase_39 AC 1,552 ms
6,232 KB
testcase_40 AC 1,555 ms
6,248 KB
testcase_41 AC 1,551 ms
6,312 KB
testcase_42 AC 1,555 ms
6,260 KB
testcase_43 AC 1,548 ms
6,284 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(20, 21) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]
/home/judge/data/code/Main.nim(30, 21) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]
/home/judge/data/code/Main.nim(40, 21) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]
/home/judge/data/code/Main.nim(50, 21) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]
/home/judge/data/code/Main.nim(60, 21) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]
/home/judge/data/code/Main.nim(72, 21) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]
/home/judge/data/code/Main.nim(83, 21) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]
/home/judge/data/code/Main.nim(94, 21) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]
/home/judge/data/code/Main.nim(105, 21) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]

ソースコード

diff #

import strutils, sequtils, sets

when isMainModule:
  var
    tmp = stdin.readLine.split.map(parseInt)
    (n, m) = (tmp[0], tmp[1])
    a = newSeqWith(m, newSeqWith(n, newSeq[int](n)))

  for i in 0..m-1:
    for j in 0..n-1:
      a[i][j] = stdin.readLine.split.map(parseInt)

  var min = 1 shl 30

  for i in 0..m-1:
    for j in i+1..m-1:
      # yoko * yoko
      for li in 0..n-1:
        for lj in 0..n-1:
          var cnt = initSet[int]()
          for ci in 0..n-1:
            cnt.incl(a[i][li][ci])
          for cj in 0..n-1:
            cnt.incl(a[j][lj][cj])
          min = min(min, cnt.len)

      # tate * tate
      for ci in 0..n-1:
        for cj in 0..n-1:
          var cnt = initSet[int]()
          for li in 0..n-1:
            cnt.incl(a[i][li][ci])
          for lj in 0..n-1:
            cnt.incl(a[j][lj][cj])
          min = min(min, cnt.len)

      # yoko * tate
      for li in 0..n-1:
        for cj in 0..n-1:
          var cnt = initSet[int]()
          for ci in 0..n-1:
            cnt.incl(a[i][li][ci])
          for lj in 0..n-1:
            cnt.incl(a[j][lj][cj])
          min = min(min, cnt.len)

      # tate * yoko
      for ci in 0..n-1:
        for lj in 0..n-1:
          var cnt = initSet[int]()
          for li in 0..n-1:
            cnt.incl(a[i][li][ci])
          for cj in 0..n-1:
            cnt.incl(a[j][lj][cj])
          min = min(min, cnt.len)

      # naname * naname
      for si in 0..1:
        for sj in 0..1:
          var cnt = initSet[int]()
          for k in 0..n-1:
            if si == 0: cnt.incl(a[i][k][k])
            else: cnt.incl(a[i][k][n-k-1])
          for k in 0..n-1:
            if sj == 0: cnt.incl(a[j][k][k])
            else: cnt.incl(a[j][k][n-k-1])
          min = min(min, cnt.len)

      # yoko * naname
      for li in 0..n-1:
        for sj in 0..1:
          var cnt = initSet[int]()
          for ci in 0..n-1:
            cnt.incl(a[i][li][ci])
          for k in 0..n-1:
            if sj == 0: cnt.incl(a[j][k][k])
            else: cnt.incl(a[j][k][n-k-1])
          min = min(min, cnt.len)

      # naname * yoko
      for si in 0..1:
        for lj in 0..n-1:
          var cnt = initSet[int]()
          for k in 0..n-1:
            if si == 0: cnt.incl(a[i][k][k])
            else: cnt.incl(a[i][k][n-k-1])
          for cj in 0..n-1:
            cnt.incl(a[j][lj][cj])
          min = min(min, cnt.len)

      # tate * naname
      for ci in 0..n-1:
        for sj in 0..1:
          var cnt = initSet[int]()
          for li in 0..n-1:
            cnt.incl(a[i][li][ci])
          for k in 0..n-1:
            if sj == 0: cnt.incl(a[j][k][k])
            else: cnt.incl(a[j][k][n-k-1])
          min = min(min, cnt.len)

      # naname * tate
      for si in 0..1:
        for cj in 0..n-1:
          var cnt = initSet[int]()
          for k in 0..n-1:
            if si == 0: cnt.incl(a[i][k][k])
            else: cnt.incl(a[i][k][n-k-1])
          for lj in 0..n-1:
            cnt.incl(a[j][lj][cj])
          min = min(min, cnt.len)

  echo min - 1
0