結果

問題 No.2463 ストレートフラッシュ
ユーザー AerenAeren
提出日時 2023-09-08 21:55:55
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,351 bytes
コンパイル時間 4,110 ms
コンパイル使用メモリ 369,372 KB
実行使用メモリ 5,992 KB
最終ジャッジ日時 2023-09-08 21:56:17
合計ジャッジ時間 6,065 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 41 ms
5,076 KB
testcase_14 AC 50 ms
5,396 KB
testcase_15 AC 47 ms
5,140 KB
testcase_16 AC 50 ms
5,340 KB
testcase_17 AC 59 ms
5,652 KB
testcase_18 AC 63 ms
5,936 KB
testcase_19 AC 63 ms
5,936 KB
testcase_20 AC 62 ms
5,932 KB
testcase_21 AC 52 ms
5,880 KB
testcase_22 AC 54 ms
5,916 KB
testcase_23 AC 55 ms
5,880 KB
testcase_24 AC 55 ms
5,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n, m;
	cin >> n >> m;
	vector<array<int, 2>> a(n * m);
	vector pos(n, vector<int>(m));
	for(auto i = 0; i < n * m; ++ i){
		cin >> a[i][0] >> a[i][1], -- a[i][0], -- a[i][1];
		pos[a[i][0]][a[i][1]] = i;
	}
	int res = numeric_limits<int>::max();
	for(auto xs = 0; xs + 5 <= n + 1; ++ xs){
		for(auto y = 0; y < m; ++ y){
			array<int, 5> p;
			for(auto dx = 0; dx < 5; ++ dx){
				p[dx] = pos[(xs + dx) % n][y];
			}
			ranges::sort(p);
			int last = -1, cur = -1;
			for(auto pick = 0; pick < 5; ++ pick){
				int i = p[pick], jump = 5 - pick;
				cur += (i - last + jump - 1) / jump;
				last += (i - last + jump - 1) / jump * jump;
			}
			res = min(res, cur);
		}
	}
	cout << res << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////
0