結果

問題 No.452 横着者のビンゴゲーム
ユーザー t8m8⛄️t8m8⛄️
提出日時 2016-12-03 16:13:17
言語 Nim
(2.0.2)
結果
AC  
実行時間 2,870 ms / 3,000 ms
コード長 3,063 bytes
コンパイル時間 4,384 ms
コンパイル使用メモリ 70,016 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-29 20:57:05
合計ジャッジ時間 26,120 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 6 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2,870 ms
5,376 KB
testcase_15 AC 2,744 ms
5,376 KB
testcase_16 AC 1,492 ms
5,376 KB
testcase_17 AC 177 ms
5,376 KB
testcase_18 AC 113 ms
5,376 KB
testcase_19 AC 103 ms
5,376 KB
testcase_20 AC 105 ms
5,376 KB
testcase_21 AC 316 ms
5,376 KB
testcase_22 AC 112 ms
5,376 KB
testcase_23 AC 845 ms
5,376 KB
testcase_24 AC 118 ms
5,376 KB
testcase_25 AC 49 ms
5,376 KB
testcase_26 AC 315 ms
5,376 KB
testcase_27 AC 232 ms
5,376 KB
testcase_28 AC 129 ms
5,376 KB
testcase_29 AC 98 ms
5,376 KB
testcase_30 AC 395 ms
5,376 KB
testcase_31 AC 61 ms
5,376 KB
testcase_32 AC 60 ms
5,376 KB
testcase_33 AC 174 ms
5,376 KB
testcase_34 AC 138 ms
5,376 KB
testcase_35 AC 146 ms
5,376 KB
testcase_36 AC 62 ms
5,376 KB
testcase_37 AC 86 ms
5,376 KB
testcase_38 AC 1,752 ms
5,376 KB
testcase_39 AC 1,479 ms
5,376 KB
testcase_40 AC 1,489 ms
5,376 KB
testcase_41 AC 1,483 ms
5,376 KB
testcase_42 AC 1,475 ms
5,376 KB
testcase_43 AC 1,486 ms
5,376 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