結果
問題 | No.452 横着者のビンゴゲーム |
ユーザー |
![]() |
提出日時 | 2016-12-03 21:44:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,639 bytes |
コンパイル時間 | 1,146 ms |
コンパイル使用メモリ | 96,292 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-11-27 19:11:17 |
合計ジャッジ時間 | 42,084 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 TLE * 6 |
ソースコード
#include <algorithm>#include <cstdio>#include <cstdlib>#include <cctype>#include <cmath>#include <iostream>#include <queue>#include <list>#include <stack>#include <map>#include <numeric>#include <set>#include <sstream>#include <string>#include <vector>using namespace std;#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)#define rep(i,n) REP(i,0,n)#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)#define ALLOF(c) (c).begin(), (c).end()typedef long long ll;struct ST {int m;vector<int> v;ST(int n):v(n,0){}};ll calc(const ST& a, const ST& b){map<int,int> memo;rep(i,a.v.size()){memo[a.v[i]]++;memo[b.v[i]]++;}ll ret = 0;FOR(it,memo){if(it->second == 2) ret++;}return ret;}int main(){ios::sync_with_stdio(false);int N, M;cin >> N >> M;vector<ST> v;rep(i,M){vector< vector<int> > card(N, vector<int>(N, 0));rep(j,N){rep(k,N){cin >> card[j][k];}}rep(j,N){ST st(N);st.m = i;rep(k,N) st.v[k] = card[j][k];v.push_back(st);}rep(k,N){ST st(N);st.m = i;rep(j,N) st.v[j] = card[j][k];v.push_back(st);}{ST st1(N), st2(N);st1.m = i;st2.m = i;rep(j,N){st1.v[j] = card[j][j];st2.v[j] = card[j][N-1-j];}v.push_back(st1);v.push_back(st2);}}ll c = 0;rep(i,v.size()){REP(j,i+1,v.size()){if(v[i].m == v[j].m) continue;c = max(c, calc(v[i], v[j]));}}cout << 2LL*N - c - 1 << endl;return 0;}