結果

問題 No.452 横着者のビンゴゲーム
ユーザー face4face4
提出日時 2019-10-17 17:30:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 516 ms / 3,000 ms
コード長 1,274 bytes
コンパイル時間 895 ms
コンパイル使用メモリ 79,292 KB
実行使用メモリ 7,632 KB
最終ジャッジ日時 2023-09-07 01:39:04
合計ジャッジ時間 6,929 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 1 ms
4,388 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 516 ms
7,632 KB
testcase_15 AC 514 ms
7,336 KB
testcase_16 AC 270 ms
5,412 KB
testcase_17 AC 26 ms
4,380 KB
testcase_18 AC 48 ms
4,376 KB
testcase_19 AC 34 ms
4,376 KB
testcase_20 AC 26 ms
4,376 KB
testcase_21 AC 118 ms
4,512 KB
testcase_22 AC 19 ms
4,376 KB
testcase_23 AC 219 ms
5,172 KB
testcase_24 AC 18 ms
4,380 KB
testcase_25 AC 9 ms
4,376 KB
testcase_26 AC 125 ms
4,456 KB
testcase_27 AC 88 ms
4,380 KB
testcase_28 AC 54 ms
4,380 KB
testcase_29 AC 35 ms
4,376 KB
testcase_30 AC 153 ms
4,784 KB
testcase_31 AC 25 ms
4,380 KB
testcase_32 AC 16 ms
4,376 KB
testcase_33 AC 65 ms
4,376 KB
testcase_34 AC 55 ms
4,380 KB
testcase_35 AC 42 ms
4,376 KB
testcase_36 AC 12 ms
4,376 KB
testcase_37 AC 13 ms
4,376 KB
testcase_38 AC 514 ms
6,584 KB
testcase_39 AC 340 ms
5,400 KB
testcase_40 AC 340 ms
5,380 KB
testcase_41 AC 351 ms
5,428 KB
testcase_42 AC 345 ms
5,412 KB
testcase_43 AC 344 ms
5,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<vector>
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]);
            }
        }
    }
    // O(M^2 N^3)
    int ans = 2*n;
    vector<bool> v(n*n*m+1,0);
    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++){
                    for(int x : s[i][k])    v[x] = true;
                    int dbl = 0;
                    for(int x : s[j][l])    dbl += v[x];
                    ans = min(ans, (n-dbl)*2+dbl-1);
                    for(int x : s[i][k])    v[x] = false;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0