結果

問題 No.452 横着者のビンゴゲーム
ユーザー olpheolphe
提出日時 2016-12-03 05:12:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,411 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 60,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 18:01:42
合計ジャッジ時間 10,539 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 402 ms
5,376 KB
testcase_15 AC 389 ms
5,376 KB
testcase_16 AC 212 ms
5,376 KB
testcase_17 AC 25 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 41 ms
5,376 KB
testcase_20 AC 33 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 29 ms
5,376 KB
testcase_23 WA -
testcase_24 AC 22 ms
5,376 KB
testcase_25 AC 13 ms
5,376 KB
testcase_26 AC 294 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 19 ms
5,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 50 ms
5,376 KB
testcase_36 AC 15 ms
5,376 KB
testcase_37 AC 16 ms
5,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "algorithm"
using namespace std;

int N, M;
int card[200][100][100];
int ans=1000;
int box;
int check[2][100];

void same() {
	int x=0, y=0;
	box = N;
	while (x<N&&y<N) {
		if (check[0][x] == check[1][y]) {
			box--;
			x++;
			y++;
		}
		else if (check[0][x]>check[1][y]) {
			y++;
			
		}
		else {
			x++;
			y++;
		}
	}
	if (ans > box)ans = box;
}
void _copy(int num,int y,int x,bool flag) {
	int a=0;
	if (!flag)a = 1;
	if (y == -1&&x!=-1) {
		for (int i = 0; i < N; i++) {
			check[a][i] = card[num][i][x];
		}
		sort(check[a], &check[a][N]);
	}
	else if (x == -1&&y!=-1) {
		for (int i = 0; i < N; i++) {
			check[a][i] = card[num][y][i];
		}
		sort(check[a], &check[a][N]);
	}
	else if(x==-1&&y==-1){
		for (int i = 0; i < N; i++) {
			check[a][i] = card[num][i][i];
		}
		sort(check[a], &check[a][N]);
	}
	else {
		for (int i = 0; i < N; i++) {
			check[a][i] = card[num][i][N-i-1];
		}
		sort(check[a], &check[a][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 >> card[i][j][k];
			}
		}
	}
	for (int h = 0; h < M; h++) {
		for (int i = 0; i < N; i++) {
			_copy(h, i, -1,true);
			for (int j = 0; j < M; j++) {
				if (h != j) {
					for (int k = 0; k < N; k++) {
						_copy(j, k, -1,false);
						same();
						_copy(j, -1, k, false);
						same();
					}
					_copy(j, -1, -1, false);
					same();
					_copy(j, 0, 0, false);
					same();
				}
			}
			_copy(h, -1, i, true);
			for (int j = 0; j < M; j++) {
				if (h != j) {
					for (int k = 0; k < N; k++) {
						_copy(j, k, -1, false);
						same();
						_copy(j, -1, k, false);
						same();
					}
					_copy(j, -1, -1, false);
					same();
					_copy(j, 0, 0, false);
					same();
				}
			}
		}
		_copy(h, -1, -1, true);
		for (int j = 0; j < M; j++) {
			if (h != j) {
				for (int k = 0; k < N; k++) {
					_copy(j, k, -1, false);
					same();
					_copy(j, -1, k, false);
					same();
				}
				_copy(j, -1, -1, false);
				same();
				_copy(j, 0, 0, false);
				same();
			}
		}
		_copy(h, 0, 0, true);
		for (int j = 0; j < M; j++) {
			if (h != j) {
				for (int k = 0; k < N; k++) {
					_copy(j, k, -1, false);
					same();
					_copy(j, -1, k, false);
					same();
				}
				_copy(j, -1, -1, false);
				same();
				_copy(j, 0, 0, false);
				same();
			}
		}
	}
	cout << ans + N-1 << "\n";
	return 0;
}
0