結果

問題 No.452 横着者のビンゴゲーム
ユーザー chaemonchaemon
提出日時 2016-12-03 00:21:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,346 ms / 3,000 ms
コード長 2,040 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 98,464 KB
実行使用メモリ 11,784 KB
最終ジャッジ日時 2023-08-19 06:55:43
合計ジャッジ時間 13,505 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 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,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,380 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 690 ms
4,380 KB
testcase_15 AC 679 ms
4,380 KB
testcase_16 AC 329 ms
4,380 KB
testcase_17 AC 70 ms
11,784 KB
testcase_18 AC 112 ms
4,380 KB
testcase_19 AC 57 ms
5,836 KB
testcase_20 AC 54 ms
5,684 KB
testcase_21 AC 288 ms
4,376 KB
testcase_22 AC 56 ms
7,712 KB
testcase_23 AC 537 ms
4,380 KB
testcase_24 AC 53 ms
9,732 KB
testcase_25 AC 23 ms
5,644 KB
testcase_26 AC 301 ms
4,380 KB
testcase_27 AC 186 ms
4,380 KB
testcase_28 AC 124 ms
4,380 KB
testcase_29 AC 71 ms
4,376 KB
testcase_30 AC 372 ms
4,380 KB
testcase_31 AC 50 ms
4,376 KB
testcase_32 AC 32 ms
5,640 KB
testcase_33 AC 138 ms
4,380 KB
testcase_34 AC 119 ms
4,376 KB
testcase_35 AC 76 ms
5,712 KB
testcase_36 AC 30 ms
5,612 KB
testcase_37 AC 40 ms
9,756 KB
testcase_38 AC 1,346 ms
4,380 KB
testcase_39 AC 862 ms
4,380 KB
testcase_40 AC 852 ms
4,376 KB
testcase_41 AC 876 ms
4,376 KB
testcase_42 AC 869 ms
4,380 KB
testcase_43 AC 874 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define REvector(a) memvector((a),0,sizeof(a))
#define vector(a) memvector((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int C[222][111][111];
vector<vector<vector<int> > > v;

int N,M;

vector<vector<int> > make_blist(int s){
	vector<vector<int> > bs;
	REP(i,N){
		vector<int> st;
		REP(j,N)st.push_back(C[s][i][j]);
		bs.push_back(st);
	}
	REP(j,N){
		vector<int> st;
		REP(i,N)st.push_back(C[s][i][j]);
		bs.push_back(st);
	}
	{
		vector<int> st;
		REP(i,N)st.push_back(C[s][i][i]);
		bs.push_back(st);
	}
	{
		vector<int> st;
		REP(i,N)st.push_back(C[s][i][N-1-i]);
		bs.push_back(st);
	}
	return bs;
}

int main(){
	cin>>N>>M;
	REP(t,M)REP(i,N)REP(j,N)cin>>C[t][i][j];
	REP(t,M){
		v.push_back(make_blist(t));
	}
	int ans = INF;
	REP(t,M)RREP(s,t+1,M){
		for(auto a:v[t])for(auto b:v[s]){
			vector<int> c = a;
			c.insert(c.end(),ALL(b));
			sort(ALL(c));
			int k = distance(c.begin(),unique(ALL(c)));
			ans = min(k,ans);
		}
	}
	cout<<max(1,ans-1)<<endl;
	return 0;
}
0