結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 409 ms
7,348 KB
testcase_15 AC 390 ms
7,288 KB
testcase_16 AC 212 ms
5,560 KB
testcase_17 AC 13 ms
4,376 KB
testcase_18 AC 84 ms
4,376 KB
testcase_19 AC 43 ms
4,380 KB
testcase_20 AC 27 ms
4,380 KB
testcase_21 AC 216 ms
4,596 KB
testcase_22 AC 17 ms
4,380 KB
testcase_23 AC 416 ms
5,184 KB
testcase_24 AC 14 ms
4,380 KB
testcase_25 AC 8 ms
4,380 KB
testcase_26 AC 229 ms
4,380 KB
testcase_27 AC 124 ms
4,376 KB
testcase_28 AC 95 ms
4,380 KB
testcase_29 AC 45 ms
4,380 KB
testcase_30 AC 278 ms
4,636 KB
testcase_31 AC 34 ms
4,376 KB
testcase_32 AC 18 ms
4,380 KB
testcase_33 AC 87 ms
4,376 KB
testcase_34 AC 87 ms
4,380 KB
testcase_35 AC 52 ms
4,376 KB
testcase_36 AC 10 ms
4,380 KB
testcase_37 AC 10 ms
4,376 KB
testcase_38 AC 1,035 ms
6,632 KB
testcase_39 AC 646 ms
5,636 KB
testcase_40 AC 643 ms
5,492 KB
testcase_41 AC 647 ms
5,372 KB
testcase_42 AC 643 ms
5,412 KB
testcase_43 AC 643 ms
5,560 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