結果
問題 | No.452 横着者のビンゴゲーム |
ユーザー |
|
提出日時 | 2016-12-05 03:21:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,621 bytes |
コンパイル時間 | 1,080 ms |
コンパイル使用メモリ | 86,900 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 21:02:52 |
合計ジャッジ時間 | 5,900 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 WA * 2 |
ソースコード
#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 (y,n) repeat (x,n) diag[y] = c[i][y][p ? x : n-x-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;}