結果

問題 No.452 横着者のビンゴゲーム
ユーザー hotpepsihotpepsi
提出日時 2016-12-04 01:21:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,963 ms / 3,000 ms
コード長 1,066 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 76,492 KB
実行使用メモリ 8,372 KB
最終ジャッジ日時 2023-08-19 09:02:16
合計ジャッジ時間 17,519 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 925 ms
8,372 KB
testcase_15 AC 896 ms
8,020 KB
testcase_16 AC 513 ms
5,644 KB
testcase_17 AC 44 ms
4,376 KB
testcase_18 AC 173 ms
4,376 KB
testcase_19 AC 83 ms
4,380 KB
testcase_20 AC 52 ms
4,380 KB
testcase_21 AC 420 ms
4,804 KB
testcase_22 AC 43 ms
4,376 KB
testcase_23 AC 823 ms
5,548 KB
testcase_24 AC 34 ms
4,380 KB
testcase_25 AC 18 ms
4,376 KB
testcase_26 AC 450 ms
4,448 KB
testcase_27 AC 243 ms
4,380 KB
testcase_28 AC 191 ms
4,376 KB
testcase_29 AC 85 ms
4,380 KB
testcase_30 AC 557 ms
4,788 KB
testcase_31 AC 64 ms
4,376 KB
testcase_32 AC 35 ms
4,380 KB
testcase_33 AC 167 ms
4,380 KB
testcase_34 AC 164 ms
4,376 KB
testcase_35 AC 101 ms
4,380 KB
testcase_36 AC 22 ms
4,380 KB
testcase_37 AC 26 ms
4,380 KB
testcase_38 AC 1,963 ms
6,992 KB
testcase_39 AC 1,268 ms
5,568 KB
testcase_40 AC 1,259 ms
5,624 KB
testcase_41 AC 1,258 ms
5,768 KB
testcase_42 AC 1,268 ms
5,652 KB
testcase_43 AC 1,276 ms
5,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <vector>
#include <cstdio>

using namespace std;
typedef long long LL;
typedef set<int> IntSet;

int get_common_length(const IntSet &a, const IntSet &b) {
	int r = 0;
	for (int x : a) {
		r += b.find(x) != b.end();
	}
	return r;
}

int main(int argc, char *argv[]) {
	int N, M;
	cin >> N >> M;
	int m = 0;
	vector<IntSet> v;
	for (int i = 0; i != M; ++i) {
		vector<IntSet> w;
		int c[100][100];
		for (int j = 0; j != N; ++j) {
			IntSet s;
			for (int k = 0; k != N; ++k) {
				cin >> c[j][k];
				s.insert(c[j][k]);
			}
			w.push_back(s);
		}
		IntSet a, b;
		for (int j = 0; j != N; ++j) {
			IntSet s;
			for (int k = 0; k != N; ++k) {
				s.insert(c[k][j]);
			}
			w.push_back(s);
			a.insert(c[j][j]);
			b.insert(c[j][N - j - 1]);
		}
		w.push_back(a);
		w.push_back(b);
		for (auto x : w) {
			for (auto y : v) {
				m = max(m, get_common_length(x, y));
			}
		}
		for (auto s : w) {
			v.push_back(s);
		}
	}
	int ans = N * 2 - m - 1;
	cout << ans << endl;
	return 0;
}
0