結果

問題 No.452 横着者のビンゴゲーム
ユーザー hotpepsi
提出日時 2016-12-04 01:21:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2,160 ms / 3,000 ms
コード長 1,066 bytes
コンパイル時間 1,134 ms
コンパイル使用メモリ 76,404 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-11-29 00:05:58
合計ジャッジ時間 18,228 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

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