結果

問題 No.452 横着者のビンゴゲーム
ユーザー mayoko_mayoko_
提出日時 2016-12-03 01:23:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,590 bytes
コンパイル時間 2,297 ms
コンパイル使用メモリ 89,256 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 17:19:22
合計ジャッジ時間 3,785 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 56 ms
5,376 KB
testcase_15 AC 56 ms
5,376 KB
testcase_16 AC 34 ms
5,376 KB
testcase_17 AC 9 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 11 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 8 ms
5,376 KB
testcase_23 AC 85 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 5 ms
5,376 KB
testcase_26 AC 52 ms
5,376 KB
testcase_27 AC 30 ms
5,376 KB
testcase_28 AC 23 ms
5,376 KB
testcase_29 AC 13 ms
5,376 KB
testcase_30 AC 63 ms
5,376 KB
testcase_31 AC 11 ms
5,376 KB
testcase_32 AC 7 ms
5,376 KB
testcase_33 WA -
testcase_34 AC 22 ms
5,376 KB
testcase_35 AC 16 ms
5,376 KB
testcase_36 AC 5 ms
5,376 KB
testcase_37 AC 6 ms
5,376 KB
testcase_38 AC 191 ms
5,376 KB
testcase_39 AC 127 ms
5,376 KB
testcase_40 AC 127 ms
5,376 KB
testcase_41 WA -
testcase_42 AC 124 ms
5,376 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAXM = 222;
const int MAXN = 111;

int C[MAXM][MAXN][MAXN];
bool done[MAXN][MAXN];
int N, M;

int cnt() {
	int ret = N;
	for (int i = 0; i < N; i++) {
		int tmp = 0;
		for (int j = 0; j < N; j++) {
			if (done[i][j]) ++tmp;
		}
		ret = min(ret, N-tmp);
	}
	for (int j = 0; j < N; j++) {
		int tmp = 0;
		for (int i = 0; i < N; i++) {
			if (done[i][j]) ++tmp;
		}
		ret = min(ret, N-tmp);
	}
	int tmp = 0;
	for (int i = 0; i < N; i++) {
		if (done[i][i]) ++tmp;
	}
	ret = min(ret, N-tmp);
	tmp = 0;
	for (int i = 0; i < N; i++) {
		if (done[i][N-1-i]) ++tmp;
	}
	ret = min(ret, N-tmp);
	return ret;
}

int calc(int a, int b) {
	int ans = N-1;
	for (int i = 0; i < N; i++) {
		set<int> S;
		for (int j = 0; j < N; j++) {
			S.insert(C[a][i][j]);
		}
		memset(done, false, sizeof(done));
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (S.find(C[b][i][j]) != S.end()) done[i][j] = true;
			}
		}
		ans = min(ans, cnt()-1);
	}
	return ans+N;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				cin >> C[i][j][k];
			}
		}
	}
	int ans = 2*N-1;
	for (int i = 0; i < M; i++) {
		for (int j = i+1; j < M; j++) {
			ans = min(ans, calc(i, j));
		}
	}
	cout << ans << endl;
	return 0;
}
0