結果

問題 No.452 横着者のビンゴゲーム
ユーザー face4face4
提出日時 2019-10-17 17:16:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 975 ms / 3,000 ms
コード長 1,131 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 75,664 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2023-09-07 01:23:21
合計ジャッジ時間 9,453 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 372 ms
7,424 KB
testcase_15 AC 355 ms
7,208 KB
testcase_16 AC 187 ms
5,348 KB
testcase_17 AC 13 ms
4,380 KB
testcase_18 AC 77 ms
4,376 KB
testcase_19 AC 41 ms
4,376 KB
testcase_20 AC 27 ms
4,380 KB
testcase_21 AC 201 ms
4,464 KB
testcase_22 AC 16 ms
4,380 KB
testcase_23 AC 391 ms
5,292 KB
testcase_24 AC 14 ms
4,376 KB
testcase_25 AC 9 ms
4,376 KB
testcase_26 AC 214 ms
4,420 KB
testcase_27 AC 110 ms
4,376 KB
testcase_28 AC 88 ms
4,376 KB
testcase_29 AC 41 ms
4,376 KB
testcase_30 AC 251 ms
4,620 KB
testcase_31 AC 30 ms
4,376 KB
testcase_32 AC 18 ms
4,380 KB
testcase_33 AC 80 ms
4,376 KB
testcase_34 AC 76 ms
4,376 KB
testcase_35 AC 50 ms
4,376 KB
testcase_36 AC 10 ms
4,380 KB
testcase_37 AC 10 ms
4,376 KB
testcase_38 AC 975 ms
6,492 KB
testcase_39 AC 607 ms
5,380 KB
testcase_40 AC 600 ms
5,564 KB
testcase_41 AC 604 ms
5,440 KB
testcase_42 AC 600 ms
5,360 KB
testcase_43 AC 594 ms
5,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
using namespace std;

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    int c[m][n][n];
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n*n; j++){
            cin >> c[i][j/n][j%n];
        }
    }
    set<int> s[m][2*n+2];
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            s[i][2*n].insert(c[i][j][j]);
            s[i][2*n+1].insert(c[i][n-1-j][j]);
        }
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                s[i][j].insert(c[i][j][k]);
                s[i][n+j].insert(c[i][k][j]);
            }
        }
    }
    // (MN)^2 NlogN
    int ans = 2*n;
    for(int i = 0; i < m; i++){
        for(int j = i+1; j < m; j++){
            for(int k = 0; k < 2*n+2; k++){
                for(int l = 0; l < 2*n+2; l++){
                    int dbl = 0;
                    for(int x : s[j][l])    dbl += s[i][k].count(x);
                    ans = min(ans, (n-dbl)*2+dbl-1);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0