結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 12 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 1,754 ms
4,376 KB
testcase_17 AC 126 ms
4,380 KB
testcase_18 AC 520 ms
4,376 KB
testcase_19 AC 280 ms
4,380 KB
testcase_20 AC 158 ms
4,376 KB
testcase_21 AC 1,309 ms
4,376 KB
testcase_22 AC 117 ms
4,380 KB
testcase_23 AC 2,436 ms
4,376 KB
testcase_24 AC 87 ms
4,376 KB
testcase_25 AC 51 ms
4,380 KB
testcase_26 AC 1,430 ms
4,380 KB
testcase_27 AC 881 ms
4,380 KB
testcase_28 AC 595 ms
4,376 KB
testcase_29 AC 315 ms
4,376 KB
testcase_30 AC 1,709 ms
4,376 KB
testcase_31 AC 230 ms
4,380 KB
testcase_32 AC 112 ms
4,380 KB
testcase_33 AC 625 ms
4,380 KB
testcase_34 AC 571 ms
4,380 KB
testcase_35 AC 338 ms
4,376 KB
testcase_36 AC 66 ms
4,376 KB
testcase_37 AC 65 ms
4,376 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< vector<ST> > w;
  
  rep(i,M){
    vector<ST> v;
    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);
    }
    w.push_back(v);
  }

  ll c = 0;
  rep(i,w.size()){
    rep(ii,w[i].size()){
      REP(j,i+1,w.size()){
        rep(jj,w[j].size()){
          c = max(c, calc(w[i][ii], w[j][jj]));
        }
      }
    }
  }

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

0