結果

問題 No.2463 ストレートフラッシュ
ユーザー Today03Today03
提出日時 2023-09-08 22:27:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 956 bytes
コンパイル時間 3,863 ms
コンパイル使用メモリ 211,944 KB
実行使用メモリ 9,420 KB
最終ジャッジ日時 2023-09-08 22:28:14
合計ジャッジ時間 7,219 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,768 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 34 ms
4,376 KB
testcase_10 AC 5 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 10 ms
4,380 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> D(n * m);
	vector<vector<int>> nm(m, vector<int>(n));
	for (int i = 0; i < n * m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		nm[v][u] = max(i - 4, 0);
		D[i] = make_pair(v, u);
	}
	int ans = INT_MAX;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n - 3; j++) {
			set<pair<int, int>> mem;
			int k = j;
			do {
				mem.insert(make_pair(i, k));
				(++k) %= n;
			} while (k != (j + 5) % n);
			set<pair<int, int>> cd;
			for (pair<int, int> x : mem) {
				if (nm[x.first][x.second] == 0) {
					cd.insert(x);
				}
			}
			int time = 5;
			int res = 0;
			while (mem != cd) {
				int add = min(n * m - time, 5 - (int)cd.size());
				for (int k = 0; k < add; k++) {
					if (mem.count(D[time + k])) {
						cd.insert(D[time + k]);
					}
				}
				time += add;
				res++;
			}
			ans = min(ans, res);
		}
	}
	cout << ans << endl;
}
0