結果

問題 No.452 横着者のビンゴゲーム
ユーザー kotamanegikotamanegi
提出日時 2017-01-05 00:14:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 244 ms / 3,000 ms
コード長 1,870 bytes
コンパイル時間 1,752 ms
コンパイル使用メモリ 97,144 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 12:09:20
合計ジャッジ時間 4,662 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 37 ms
4,376 KB
testcase_15 AC 37 ms
4,376 KB
testcase_16 AC 25 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 26 ms
4,376 KB
testcase_19 AC 18 ms
4,380 KB
testcase_20 AC 13 ms
4,376 KB
testcase_21 AC 59 ms
4,376 KB
testcase_22 AC 11 ms
4,380 KB
testcase_23 AC 105 ms
4,380 KB
testcase_24 AC 7 ms
4,376 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 65 ms
4,380 KB
testcase_27 AC 46 ms
4,376 KB
testcase_28 AC 29 ms
4,380 KB
testcase_29 AC 19 ms
4,376 KB
testcase_30 AC 76 ms
4,380 KB
testcase_31 AC 14 ms
4,376 KB
testcase_32 AC 9 ms
4,376 KB
testcase_33 AC 34 ms
4,380 KB
testcase_34 AC 30 ms
4,380 KB
testcase_35 AC 23 ms
4,376 KB
testcase_36 AC 7 ms
4,380 KB
testcase_37 AC 6 ms
4,376 KB
testcase_38 AC 244 ms
4,380 KB
testcase_39 AC 167 ms
4,376 KB
testcase_40 AC 167 ms
4,380 KB
testcase_41 AC 167 ms
4,380 KB
testcase_42 AC 168 ms
4,376 KB
testcase_43 AC 167 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 100000000000000
vector<vector<int>> neko[300];
int main() {
	iostream::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 0;i < m;++i) {
		vector<int> tate[110],yoko[110],w,te;
		for (int q = 0;q < n;++q) {
			for (int j = 0;j < n;++j) {
				int a;
				cin >> a;
				tate[q].push_back(a);
				yoko[j].push_back(a);
				if (q == j) w.push_back(a);
				if ((n - q - 1) == j) te.push_back(a);
			}
		}
		for (int q = 0;q < n;++q) {
			sort(tate[q].begin(), tate[q].end());
			sort(yoko[q].begin(), yoko[q].end());
			neko[i].push_back(tate[q]);
			neko[i].push_back(yoko[q]);
		}
		sort(w.begin(), w.end());
		sort(te.begin(), te.end());
		neko[i].push_back(w);
		neko[i].push_back(te);
	}
	int ans = 100000;
	for (int i = 0;i < m;++i) {
		for (int q = 0;q < neko[i].size();++q) {
			for (int j = i + 1;j < m;++j) {
				for (int t = 0;t < neko[j].size();++t) {
					int cnt = neko[i][q].size() + neko[j][t].size();
					int left = 0;
					int right = 0;
					while (left != neko[i][q].size() && right != neko[j][t].size()) {
						if (neko[i][q][left] == neko[j][t][right]) {
							cnt--;
							left++;
							right++;
						}
						else if (neko[i][q][left] > neko[j][t][right]) {
							right++;
						}
						else {
							left++;
						}
					}
					ans = min(cnt, ans);
				}
			}
		}
	}
	cout << ans-1 << endl;
	return 0;
}
0