結果

問題 No.452 横着者のビンゴゲーム
ユーザー koyoprokoyopro
提出日時 2020-01-04 22:20:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,487 ms / 3,000 ms
コード長 1,986 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 167,788 KB
実行使用メモリ 42,316 KB
最終ジャッジ日時 2024-05-02 08:52:37
合計ジャッジ時間 22,015 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 6 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 7 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1,323 ms
6,944 KB
testcase_15 AC 1,256 ms
6,940 KB
testcase_16 AC 698 ms
6,940 KB
testcase_17 AC 58 ms
42,316 KB
testcase_18 AC 228 ms
6,940 KB
testcase_19 AC 135 ms
11,784 KB
testcase_20 AC 84 ms
17,796 KB
testcase_21 AC 581 ms
6,944 KB
testcase_22 AC 66 ms
26,064 KB
testcase_23 AC 1,070 ms
6,944 KB
testcase_24 AC 48 ms
36,304 KB
testcase_25 AC 32 ms
17,772 KB
testcase_26 AC 666 ms
6,940 KB
testcase_27 AC 411 ms
9,532 KB
testcase_28 AC 270 ms
6,944 KB
testcase_29 AC 148 ms
9,716 KB
testcase_30 AC 763 ms
6,940 KB
testcase_31 AC 100 ms
7,520 KB
testcase_32 AC 53 ms
11,800 KB
testcase_33 AC 266 ms
9,644 KB
testcase_34 AC 245 ms
7,540 KB
testcase_35 AC 155 ms
15,716 KB
testcase_36 AC 37 ms
19,792 KB
testcase_37 AC 35 ms
30,164 KB
testcase_38 AC 2,487 ms
6,944 KB
testcase_39 AC 1,673 ms
6,944 KB
testcase_40 AC 1,684 ms
6,940 KB
testcase_41 AC 1,678 ms
6,944 KB
testcase_42 AC 1,687 ms
6,940 KB
testcase_43 AC 1,676 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

/*================================*/

int N,M,L;
int C[222][222][222];

void set_line(set<int> *line, int m, int l) {
    if (l<N) {
        // 横
        REP(i,N) line->insert(C[m][l][i]);
    }
    else if (l<2*N) {
        // 縦
        REP(i,N) line->insert(C[m][i][l-N]);
    }
    else if (l==2*N) {
        // 斜め
        REP(i,N) line->insert(C[m][i][i]);
    }
    else {
        // 斜め(逆)
        REP(i,N) line->insert(C[m][i][N-1-i]);
    }
}

signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin>>N>>M;
    
    REP(m,M) {
        REP(i,N)REP(j,N)cin>>C[m][i][j];
    }
    int ma = 0; // 最大マッチ数
    REP(m,M-1) {
        REP(l,2*N+2) {
            // 各列について
            set<int> line1;
            set_line(&line1,m,l);
            FOR(o,m+1,M) {
                REP(r,2*N+2) {
                    // 他人の各列と比較
                    set<int> line2;
                    set_line(&line2,o,r);
                    set<int> result;
                    set_intersection(line1.begin(), line1.end(),
                                     line2.begin(), line2.end(),
                                     std::inserter(result, result.end()));
                    ma = max(ma, (int)result.size());
                }
            }
        }
    }
    
    cout << 2*N-1-ma << endl;
    
    return 0;
}
0