結果

問題 No.2463 ストレートフラッシュ
ユーザー shobonvipshobonvip
提出日時 2023-09-08 22:32:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 1,334 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 204,892 KB
実行使用メモリ 6,068 KB
最終ジャッジ日時 2023-09-08 22:32:41
合計ジャッジ時間 5,709 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 136 ms
5,204 KB
testcase_14 AC 164 ms
5,352 KB
testcase_15 AC 151 ms
5,044 KB
testcase_16 AC 161 ms
5,352 KB
testcase_17 AC 193 ms
5,640 KB
testcase_18 AC 202 ms
6,068 KB
testcase_19 AC 205 ms
5,956 KB
testcase_20 AC 203 ms
5,852 KB
testcase_21 AC 165 ms
6,020 KB
testcase_22 AC 162 ms
6,048 KB
testcase_23 AC 164 ms
5,968 KB
testcase_24 AC 188 ms
6,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, m; cin >> n >> m;
	vector<vector<int>> ind(n, vector<int>(m));
	vector<int> x(n*m), y(n*m);
	for (int i=0; i<n*m; i++){
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
		ind[x[i]][y[i]] = i;
	}
	int ans = 998244353;
	for (int stx=0; stx<n-3; stx++){
		for (int sty=0; sty<m; sty++){
			vector<bool> seen(5);
			vector<int> pivx(5);
			for (int i=0; i<5; i++){
				pivx[i] = (stx+i)%n;
			}
			int piv = 0;
			for (int i=0; i<5; i++){
				for (int j=0; j<5; j++){
					if (x[i] == pivx[j] && y[i] == sty){
						seen[j] = true;
						piv++;
					}
				}
			}
			int zan = 0;
			for (int i=0; i<5; i++){
				if (!seen[i]){
					zan++;
				}
			}
			int tmp = 0;
			while(zan != 0){
				int gomin = 998244353;
				for (int i=0; i<5; i++){
					if (!seen[i]){
						gomin = min(gomin, ind[pivx[i]][sty]);
					}
				}
				int tobu = (gomin - piv) / zan;
				piv += tobu * zan;
				tmp += tobu;
				int hod = 0;
				for (int i=0; i<zan; i++){
					for (int j=0; j<5; j++){
						if (i+piv >= n*m) continue;
						if (x[i+piv] == pivx[j] && y[i+piv] == sty){
							seen[j] = true;
							hod++;
						}
					}
				}
				piv += hod;
				zan = 0;
				for (int i=0; i<5; i++){
					if (!seen[i]){
						zan++;
					}
				}
			}
			ans = min(ans, tmp);
		}
	}
	cout << ans << '\n';
}
0