結果

問題 No.452 横着者のビンゴゲーム
ユーザー is_eri23is_eri23
提出日時 2016-12-17 04:40:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 263 ms / 3,000 ms
コード長 3,007 bytes
コンパイル時間 1,293 ms
コンパイル使用メモリ 151,680 KB
実行使用メモリ 5,004 KB
最終ジャッジ日時 2023-08-20 21:43:52
合計ジャッジ時間 4,841 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,396 KB
testcase_01 AC 2 ms
4,416 KB
testcase_02 AC 3 ms
4,524 KB
testcase_03 AC 3 ms
4,428 KB
testcase_04 AC 2 ms
4,580 KB
testcase_05 AC 3 ms
4,472 KB
testcase_06 AC 2 ms
4,468 KB
testcase_07 AC 2 ms
4,580 KB
testcase_08 AC 3 ms
4,584 KB
testcase_09 AC 3 ms
4,416 KB
testcase_10 AC 3 ms
4,504 KB
testcase_11 AC 3 ms
4,432 KB
testcase_12 AC 2 ms
4,480 KB
testcase_13 AC 2 ms
4,528 KB
testcase_14 AC 48 ms
4,900 KB
testcase_15 AC 46 ms
5,004 KB
testcase_16 AC 31 ms
4,700 KB
testcase_17 AC 8 ms
4,456 KB
testcase_18 AC 29 ms
4,540 KB
testcase_19 AC 21 ms
4,712 KB
testcase_20 AC 15 ms
4,556 KB
testcase_21 AC 65 ms
4,572 KB
testcase_22 AC 14 ms
4,500 KB
testcase_23 AC 114 ms
4,624 KB
testcase_24 AC 9 ms
4,496 KB
testcase_25 AC 7 ms
4,596 KB
testcase_26 AC 72 ms
4,488 KB
testcase_27 AC 51 ms
4,540 KB
testcase_28 AC 33 ms
4,748 KB
testcase_29 AC 21 ms
4,644 KB
testcase_30 AC 82 ms
4,696 KB
testcase_31 AC 16 ms
4,512 KB
testcase_32 AC 12 ms
4,444 KB
testcase_33 AC 38 ms
4,592 KB
testcase_34 AC 33 ms
4,516 KB
testcase_35 AC 28 ms
4,568 KB
testcase_36 AC 8 ms
4,444 KB
testcase_37 AC 7 ms
4,496 KB
testcase_38 AC 263 ms
4,836 KB
testcase_39 AC 180 ms
4,688 KB
testcase_40 AC 181 ms
4,644 KB
testcase_41 AC 181 ms
4,668 KB
testcase_42 AC 181 ms
4,696 KB
testcase_43 AC 181 ms
4,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

vector <int> bd[210][210];
int calc(const vector <int> &A, const vector <int> &B){
  assert(sz(B) == sz(A));
  int N = sz(A);
  int cnt = 0;
  for (int i = 0, j = 0; i < N; i++) {
    while (j < N && A[i] > B[j]) {
      j++;
    }
    if (j < N && A[i] == B[j]) {
      cnt += 1;
    }
  }
  return max(1, 2 * N - cnt - 1);
}
int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N, M; cin >> N >> M;
  rep(i,M){
    vector <int>r;
    vector <int>l;
    rep(j,N){
      rep(k,N){
        int x;
        cin >> x;
        bd[i][j].pb(x);
        bd[i][N+k].pb(x);
        if (j + k == N-1) {
          r.pb(x);
        }
        if (j == k) {
          l.pb(x);
        }
      }
    }
    bd[i][N*2] = move(r);
    bd[i][N*2+1] = move(l);
    rep(j,2*N+2){
      sort(ALL(bd[i][j]));
    }
  }
  int ans = INF;
  rep(i,M){
    rep(j,2*N+2){
      rep2(k,i+1,M){
        rep(l,2*N+2){
          ans = min(ans, calc(bd[i][j], bd[k][l]));
        }
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

0