結果

問題 No.452 横着者のビンゴゲーム
ユーザー tsutajtsutaj
提出日時 2016-12-07 15:24:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,137 ms / 3,000 ms
コード長 2,470 bytes
コンパイル時間 1,347 ms
コンパイル使用メモリ 106,144 KB
実行使用メモリ 9,536 KB
最終ジャッジ日時 2023-08-19 09:08:11
合計ジャッジ時間 10,467 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,456 KB
testcase_01 AC 3 ms
5,488 KB
testcase_02 AC 3 ms
5,388 KB
testcase_03 AC 4 ms
5,776 KB
testcase_04 AC 3 ms
5,404 KB
testcase_05 AC 4 ms
5,516 KB
testcase_06 AC 2 ms
5,380 KB
testcase_07 AC 3 ms
5,412 KB
testcase_08 AC 3 ms
5,424 KB
testcase_09 AC 2 ms
5,600 KB
testcase_10 AC 2 ms
5,492 KB
testcase_11 AC 3 ms
5,464 KB
testcase_12 AC 3 ms
5,640 KB
testcase_13 AC 3 ms
5,476 KB
testcase_14 AC 391 ms
9,536 KB
testcase_15 AC 381 ms
9,480 KB
testcase_16 AC 197 ms
7,348 KB
testcase_17 AC 14 ms
5,508 KB
testcase_18 AC 88 ms
5,908 KB
testcase_19 AC 44 ms
5,688 KB
testcase_20 AC 28 ms
5,540 KB
testcase_21 AC 234 ms
6,544 KB
testcase_22 AC 18 ms
5,524 KB
testcase_23 AC 451 ms
7,156 KB
testcase_24 AC 14 ms
5,544 KB
testcase_25 AC 9 ms
5,592 KB
testcase_26 AC 245 ms
6,584 KB
testcase_27 AC 125 ms
5,944 KB
testcase_28 AC 102 ms
5,976 KB
testcase_29 AC 47 ms
5,680 KB
testcase_30 AC 305 ms
6,744 KB
testcase_31 AC 35 ms
5,708 KB
testcase_32 AC 19 ms
5,516 KB
testcase_33 AC 87 ms
6,012 KB
testcase_34 AC 91 ms
5,824 KB
testcase_35 AC 54 ms
5,696 KB
testcase_36 AC 10 ms
5,572 KB
testcase_37 AC 12 ms
5,544 KB
testcase_38 AC 1,137 ms
8,640 KB
testcase_39 AC 709 ms
7,332 KB
testcase_40 AC 708 ms
7,552 KB
testcase_41 AC 715 ms
7,416 KB
testcase_42 AC 703 ms
7,428 KB
testcase_43 AC 707 ms
7,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// a, b をマージする.a に全要素が入り,b が空になる.
set<int> merge_set(set<int> a, set<int> b) {
  // b のほうが a よりサイズが小さいようにして
  if (a.size() < b.size()) swap(a, b);
  // a に b の中身を全部入れるだけ
  a.insert(b.begin(), b.end());
  return a;
}

signed main() {
    int n, m; cin >> n >> m;
    set<int> s[210][210];
    int board[110][110];
    rep(k,0,m) {
        rep(i,0,n) rep(j,0,n) {
            cin >> board[i][j];
        }
        rep(i,0,n) rep(j,0,n) {
            s[k][i].insert(board[i][j]);
        }
        rep(i,0,n) rep(j,0,n) {
            s[k][i+n].insert(board[j][i]);
        }
        rep(i,0,n) s[k][2*n].insert(board[i][i]);
        rep(i,0,n) s[k][2*n+1].insert(board[n-1-i][i]);
    }

    int ans = INF;
    rep(p1,0,m) {
        rep(p2,p1+1,m) {
            rep(i,0,2*n+2) {
                rep(j,0,2*n+2) {
                    int cnt = 0;
                    for(auto e : s[p1][i]) cnt += (s[p2][j].find(e) != s[p2][j].end());
                    ans = min(ans, (int)(2*n - cnt - 1));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0