結果
問題 |
No.452 横着者のビンゴゲーム
|
ユーザー |
![]() |
提出日時 | 2020-01-04 22:35:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,659 ms / 3,000 ms |
コード長 | 1,936 bytes |
コンパイル時間 | 2,179 ms |
コンパイル使用メモリ | 170,732 KB |
実行使用メモリ | 7,552 KB |
最終ジャッジ日時 | 2024-11-22 21:37:40 |
合計ジャッジ時間 | 16,646 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include "bits/stdc++.h" using namespace std; //#define int long long #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--) #define REP(i, n) for(int i=0; i<(n); i++) #define RREP(i, n) for(int i=(n-1); i>=0; i--) #define ALL(a) (a).begin(),(a).end() #define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end()); #define CONTAIN(a, b) find(ALL(a), (b)) != (a).end() #define array2(type, x, y) array<array<type, y>, x> #define vector2(type) vector<vector<type> > #define out(...) printf(__VA_ARGS__) int dxy[] = {0, 1, 0, -1, 0}; /*================================*/ int N,M,L; int C[222][222][222]; void set_line(set<int> *line, int m, int l) { line->clear(); if (l<N) { // 横 REP(i,N) line->insert(C[m][l][i]); } else if (l<2*N) { // 縦 REP(i,N) line->insert(C[m][i][l-N]); } else if (l==2*N) { // 斜め REP(i,N) line->insert(C[m][i][i]); } else { // 斜め(逆) REP(i,N) line->insert(C[m][i][N-1-i]); } } vector<set<int>> S[222]; signed main() { #if DEBUG std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); #endif cin>>N>>M; REP(m,M) { REP(i,N)REP(j,N)cin>>C[m][i][j]; REP(l,2*N+2) { set<int> line; set_line(&line, m, l); S[m].push_back(line); } } int ma = 0; // 最大マッチ数 REP(m,M-1) { for (auto l : S[m]) { FOR(o,m+1,M) { for (auto r : S[o]) { set<int> result; set_intersection(l.begin(), l.end(), r.begin(), r.end(), std::inserter(result, result.end())); ma = max(ma, (int)result.size()); } } } } cout << 2*N-1-ma << endl; return 0; }