結果

問題 No.452 横着者のビンゴゲーム
ユーザー furafura
提出日時 2020-10-13 00:10:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 308 ms / 3,000 ms
コード長 1,137 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 210,912 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 23:51:35
合計ジャッジ時間 6,508 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 50 ms
4,380 KB
testcase_15 AC 51 ms
4,376 KB
testcase_16 AC 32 ms
4,380 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 33 ms
4,376 KB
testcase_19 AC 24 ms
4,380 KB
testcase_20 AC 18 ms
4,380 KB
testcase_21 AC 76 ms
4,376 KB
testcase_22 AC 14 ms
4,376 KB
testcase_23 AC 132 ms
4,376 KB
testcase_24 AC 8 ms
4,376 KB
testcase_25 AC 7 ms
4,376 KB
testcase_26 AC 86 ms
4,380 KB
testcase_27 AC 63 ms
4,376 KB
testcase_28 AC 38 ms
4,376 KB
testcase_29 AC 24 ms
4,376 KB
testcase_30 AC 98 ms
4,380 KB
testcase_31 AC 18 ms
4,376 KB
testcase_32 AC 12 ms
4,376 KB
testcase_33 AC 45 ms
4,384 KB
testcase_34 AC 40 ms
4,380 KB
testcase_35 AC 31 ms
4,380 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 6 ms
4,376 KB
testcase_38 AC 308 ms
4,380 KB
testcase_39 AC 216 ms
4,376 KB
testcase_40 AC 212 ms
4,380 KB
testcase_41 AC 217 ms
4,380 KB
testcase_42 AC 215 ms
4,376 KB
testcase_43 AC 214 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector B(m,vector(n,vector(n,0)));
	rep(i,m) rep(x,n) rep(y,n) scanf("%d",&B[i][x][y]);

	vector seq(m,vector<vector<int>>());
	rep(i,m){
		vector<int> tmp(n);
		rep(x,n){
			rep(y,n) tmp[y]=B[i][x][y];
			seq[i].emplace_back(tmp);
		}
		rep(y,n){
			rep(x,n) tmp[x]=B[i][x][y];
			seq[i].emplace_back(tmp);
		}
		{
			rep(x,n) tmp[x]=B[i][x][x];
			seq[i].emplace_back(tmp);
			rep(x,n) tmp[x]=B[i][x][n-1-x];
			seq[i].emplace_back(tmp);
		}
		for(auto& a:seq[i]) sort(a.begin(),a.end());
	}

	int ans=2*n;
	rep(i,m) for(int j=i+1;j<m;j++) {
		for(const auto& a:seq[i]) for(const auto& b:seq[j]) {
			int idx1=0,idx2=0,cnt=0;
			while(idx1<n || idx2<n){
				if(idx1==n){
					cnt+=n-idx2;
					break;
				}
				if(idx2==n){
					cnt+=n-idx1;
					break;
				}
				if(a[idx1]==b[idx2]){
					idx1++;
					idx2++;
					cnt++;
				}
				else if(a[idx1]<b[idx2]){
					idx1++;
					cnt++;
				}
				else{
					idx2++;
					cnt++;
				}
			}
			ans=min(ans,cnt-1);
		}
	}
	printf("%d\n",ans);

	return 0;
}
0