結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 48 ms
4,376 KB
testcase_19 AC 33 ms
4,380 KB
testcase_20 AC 25 ms
4,376 KB
testcase_21 AC 117 ms
4,476 KB
testcase_22 AC 19 ms
4,376 KB
testcase_23 AC 216 ms
5,168 KB
testcase_24 AC 18 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 88 ms
4,376 KB
testcase_28 AC 53 ms
4,376 KB
testcase_29 AC 34 ms
4,376 KB
testcase_30 AC 150 ms
4,632 KB
testcase_31 AC 24 ms
4,380 KB
testcase_32 AC 16 ms
4,380 KB
testcase_33 AC 64 ms
4,380 KB
testcase_34 WA -
testcase_35 AC 40 ms
4,380 KB
testcase_36 AC 11 ms
4,376 KB
testcase_37 AC 14 ms
4,380 KB
testcase_38 AC 516 ms
6,680 KB
testcase_39 AC 346 ms
5,448 KB
testcase_40 AC 345 ms
5,492 KB
testcase_41 AC 343 ms
5,360 KB
testcase_42 AC 337 ms
5,552 KB
testcase_43 AC 341 ms
5,608 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