結果

問題 No.452 横着者のビンゴゲーム
ユーザー どららどらら
提出日時 2016-12-03 21:44:40
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,639 bytes
コンパイル時間 774 ms
コンパイル使用メモリ 91,008 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 13:45:55
合計ジャッジ時間 27,092 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 1,767 ms
4,376 KB
testcase_17 AC 124 ms
4,376 KB
testcase_18 AC 523 ms
4,380 KB
testcase_19 AC 283 ms
4,376 KB
testcase_20 AC 159 ms
4,380 KB
testcase_21 AC 1,311 ms
4,380 KB
testcase_22 AC 116 ms
4,380 KB
testcase_23 AC 2,437 ms
4,376 KB
testcase_24 AC 84 ms
4,380 KB
testcase_25 AC 51 ms
4,376 KB
testcase_26 AC 1,436 ms
4,376 KB
testcase_27 AC 885 ms
4,376 KB
testcase_28 AC 594 ms
4,376 KB
testcase_29 AC 313 ms
4,376 KB
testcase_30 AC 1,711 ms
4,380 KB
testcase_31 AC 231 ms
4,376 KB
testcase_32 AC 114 ms
4,376 KB
testcase_33 AC 629 ms
4,380 KB
testcase_34 AC 578 ms
4,376 KB
testcase_35 AC 342 ms
4,376 KB
testcase_36 AC 66 ms
4,380 KB
testcase_37 AC 63 ms
4,380 KB
testcase_38 TLE -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

struct ST {
  int m;
  vector<int> v;
  ST(int n):v(n,0){}
};

ll calc(const ST& a, const ST& b){
  map<int,int> memo;
  rep(i,a.v.size()){
    memo[a.v[i]]++;
    memo[b.v[i]]++;
  }
  ll ret = 0;
  FOR(it,memo){
    if(it->second == 2) ret++;
  }
  return ret;
}

int main(){
  ios::sync_with_stdio(false);
  
  int N, M;
  cin >> N >> M;
  vector<ST> v;
  
  rep(i,M){
    vector< vector<int> > card(N, vector<int>(N, 0));
    rep(j,N){
      rep(k,N){
        cin >> card[j][k];
      }
    }

    rep(j,N){
      ST st(N);
      st.m = i;
      rep(k,N) st.v[k] = card[j][k];
      v.push_back(st);
    }
    rep(k,N){
      ST st(N);
      st.m = i;
      rep(j,N) st.v[j] = card[j][k];
      v.push_back(st);
    }
    {
      ST st1(N), st2(N);
      st1.m = i;
      st2.m = i;
      rep(j,N){
        st1.v[j] = card[j][j];
        st2.v[j] = card[j][N-1-j];
      }
      v.push_back(st1);
      v.push_back(st2);
    }
  }

  ll c = 0;
  rep(i,v.size()){
    REP(j,i+1,v.size()){
      if(v[i].m == v[j].m) continue;
      c = max(c, calc(v[i], v[j]));
    }
  }

  cout << 2LL*N - c - 1 << endl;
    
  return 0;
}
0