結果

問題 No.452 横着者のビンゴゲーム
ユーザー tsutajtsutaj
提出日時 2016-12-07 15:09:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,510 bytes
コンパイル時間 1,203 ms
コンパイル使用メモリ 103,424 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2024-05-06 01:30:02
合計ジャッジ時間 31,742 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,504 KB
testcase_01 AC 3 ms
5,504 KB
testcase_02 AC 3 ms
5,504 KB
testcase_03 AC 9 ms
5,632 KB
testcase_04 AC 3 ms
5,504 KB
testcase_05 AC 12 ms
5,632 KB
testcase_06 AC 3 ms
5,504 KB
testcase_07 AC 3 ms
5,504 KB
testcase_08 AC 6 ms
5,504 KB
testcase_09 AC 3 ms
5,504 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 5 ms
5,504 KB
testcase_12 AC 3 ms
5,504 KB
testcase_13 AC 3 ms
5,504 KB
testcase_14 AC 2,982 ms
9,472 KB
testcase_15 AC 2,911 ms
9,344 KB
testcase_16 AC 1,569 ms
7,552 KB
testcase_17 AC 109 ms
5,504 KB
testcase_18 AC 310 ms
6,144 KB
testcase_19 AC 192 ms
5,760 KB
testcase_20 AC 132 ms
5,760 KB
testcase_21 AC 760 ms
6,784 KB
testcase_22 AC 102 ms
5,504 KB
testcase_23 AC 1,400 ms
7,424 KB
testcase_24 AC 77 ms
5,632 KB
testcase_25 AC 46 ms
5,632 KB
testcase_26 AC 849 ms
6,400 KB
testcase_27 AC 568 ms
6,016 KB
testcase_28 AC 354 ms
6,144 KB
testcase_29 AC 211 ms
5,760 KB
testcase_30 AC 995 ms
6,656 KB
testcase_31 AC 146 ms
5,760 KB
testcase_32 AC 90 ms
5,632 KB
testcase_33 AC 415 ms
5,760 KB
testcase_34 AC 363 ms
6,016 KB
testcase_35 AC 247 ms
5,760 KB
testcase_36 AC 55 ms
5,504 KB
testcase_37 AC 56 ms
5,504 KB
testcase_38 TLE -
testcase_39 AC 2,228 ms
7,552 KB
testcase_40 AC 2,202 ms
7,552 KB
testcase_41 AC 2,223 ms
7,552 KB
testcase_42 AC 2,237 ms
7,552 KB
testcase_43 AC 2,236 ms
7,552 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;
    }
}

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) {
                    set<int> temp;
                    for(auto t : s[p1][i]) temp.insert(t);
                    for(auto t : s[p2][j]) temp.insert(t);
                    // int common = (2 * n - temp.size()) / 2;

                    // printf("p1: %lld, p2: %lld\n", p1, p2);
                    // printf("p1num: %lld, p2num: %lld\n", i, j);
                    // printf("size: %lld, result: %lld\n", temp.size(), common + 2 * (n - common) - 1);
                    int sz = temp.size() - 1;
                    ans = min(ans, sz);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0