結果

問題 No.452 横着者のビンゴゲーム
ユーザー nebukuro09nebukuro09
提出日時 2016-12-03 00:46:39
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 507 ms / 3,000 ms
コード長 1,106 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 109,460 KB
実行使用メモリ 4,688 KB
最終ジャッジ日時 2023-09-02 23:15:11
合計ジャッジ時間 6,482 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 190 ms
4,688 KB
testcase_15 AC 184 ms
4,652 KB
testcase_16 AC 110 ms
4,376 KB
testcase_17 AC 25 ms
4,376 KB
testcase_18 AC 52 ms
4,376 KB
testcase_19 AC 40 ms
4,376 KB
testcase_20 AC 33 ms
4,380 KB
testcase_21 AC 120 ms
4,380 KB
testcase_22 AC 29 ms
4,380 KB
testcase_23 AC 219 ms
4,384 KB
testcase_24 AC 22 ms
4,376 KB
testcase_25 AC 14 ms
4,380 KB
testcase_26 AC 142 ms
4,376 KB
testcase_27 AC 102 ms
4,380 KB
testcase_28 AC 61 ms
4,376 KB
testcase_29 AC 41 ms
4,380 KB
testcase_30 AC 159 ms
4,380 KB
testcase_31 AC 27 ms
4,380 KB
testcase_32 AC 20 ms
4,380 KB
testcase_33 AC 74 ms
4,380 KB
testcase_34 AC 63 ms
4,380 KB
testcase_35 AC 53 ms
4,380 KB
testcase_36 AC 17 ms
4,384 KB
testcase_37 AC 16 ms
4,380 KB
testcase_38 AC 507 ms
4,380 KB
testcase_39 AC 347 ms
4,376 KB
testcase_40 AC 338 ms
4,380 KB
testcase_41 AC 340 ms
4,376 KB
testcase_42 AC 338 ms
4,376 KB
testcase_43 AC 344 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;


int N, M;

int count_diff(ref int[] A, ref int[] B) {
  A.sort();
  B.sort();
  int pa, pb, ret;
  while (pa < N && pb < N) {
    if (A[pa] == B[pb]) {ret++; pa++; pb++;}
    else if (A[pa] < B[pb]) pa++;
    else pb++;
  }
  return 2*N-ret;
}

void main() {
  auto input = readln.split.map!(to!int);
  N = input[0];
  M = input[1];
  auto B = new int[][][](M, 2*N+2, N);

  foreach (i; 0..M) {
    auto C = iota(N).map!(_ => readln.split.map!(to!int).array).array;
    foreach (j; 0..N) B[i][j] = C[j];
    foreach (j; N..2*N) foreach (k; 0..N) B[i][j][k] = C[k][j-N];
    foreach (j; 0..N) B[i][2*N][j] = C[j][j];
    foreach (j; 0..N) B[i][2*N+1][j] = C[j][N-j-1];
  }

  int ans = int.max;
  foreach (i; 0..M)
    foreach (j; i+1..M)
      foreach (a; 0..N*2+2)
        foreach (b; 0..N*2+2)
          ans = min(ans, count_diff(B[i][a], B[j][b]));

  writeln(ans-1);

}
0