結果

問題 No.452 横着者のビンゴゲーム
ユーザー kimiyukikimiyuki
提出日時 2016-12-05 03:34:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 344 ms / 3,000 ms
コード長 1,608 bytes
コンパイル時間 1,177 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-19 09:05:07
合計ジャッジ時間 6,546 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,512 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 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,380 KB
testcase_14 AC 135 ms
4,380 KB
testcase_15 AC 131 ms
4,376 KB
testcase_16 AC 109 ms
4,376 KB
testcase_17 AC 71 ms
4,380 KB
testcase_18 AC 50 ms
4,380 KB
testcase_19 AC 57 ms
4,380 KB
testcase_20 AC 59 ms
4,380 KB
testcase_21 AC 96 ms
4,380 KB
testcase_22 AC 63 ms
4,380 KB
testcase_23 AC 153 ms
4,380 KB
testcase_24 AC 53 ms
4,380 KB
testcase_25 AC 28 ms
4,380 KB
testcase_26 AC 116 ms
4,376 KB
testcase_27 AC 118 ms
4,380 KB
testcase_28 AC 56 ms
4,376 KB
testcase_29 AC 55 ms
4,376 KB
testcase_30 AC 126 ms
4,384 KB
testcase_31 AC 32 ms
4,380 KB
testcase_32 AC 36 ms
4,380 KB
testcase_33 AC 91 ms
4,380 KB
testcase_34 AC 66 ms
4,376 KB
testcase_35 AC 84 ms
4,376 KB
testcase_36 AC 35 ms
4,376 KB
testcase_37 AC 39 ms
4,384 KB
testcase_38 AC 344 ms
4,376 KB
testcase_39 AC 259 ms
4,380 KB
testcase_40 AC 259 ms
4,380 KB
testcase_41 AC 258 ms
4,380 KB
testcase_42 AC 259 ms
4,380 KB
testcase_43 AC 260 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
int main() {
    int n, m; cin >> n >> m;
    auto c = vectors(m, n, n, int());
    repeat (i,m) repeat (y,n) repeat (x,n) cin >> c[i][y][x];
    vector<vector<vector<int> > > bingo(m);
    repeat (i,m) {
        repeat (y,n) {
            vector<int> row = c[i][y];
            bingo[i].push_back(row);
        }
        repeat (x,n) {
            vector<int> col(n);
            repeat (y,n) col[y] = c[i][y][x];
            bingo[i].push_back(col);
        }
        repeat (p,2) {
            vector<int> diag(n);
            repeat (z,n) diag[z] = c[i][z][p ? z : n-z-1];
            bingo[i].push_back(diag);
        }
        for (auto & it : bingo[i]) {
            whole(sort, it);
        }
    }
    int ans = 2*n;
    repeat (i,m) for (auto & x : bingo[i]) {
        repeat (j,i) for (auto & y : bingo[j]) {
            vector<int> z;
            set_union(x.begin(), x.end(), y.begin(), y.end(), back_inserter(z));
            setmin<int>(ans, z.size()-1);
        }
    }
    cout << ans << endl;
    return 0;
}
0