結果

問題 No.2463 ストレートフラッシュ
ユーザー maeshunmaeshun
提出日時 2023-09-09 14:54:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,734 bytes
コンパイル時間 4,034 ms
コンパイル使用メモリ 240,664 KB
実行使用メモリ 6,572 KB
最終ジャッジ日時 2023-09-09 14:55:02
合計ジャッジ時間 11,447 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 256 ms
5,880 KB
testcase_14 AC 330 ms
5,944 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 371 ms
6,220 KB
testcase_18 AC 426 ms
6,140 KB
testcase_19 AC 426 ms
6,136 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:69:38: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   69 |                                 auto [a, b] = hand.front();hand.pop();
      |                                      ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> flg(m, vector<int>(n));
	vector<set<int>> st(m);
	vector<pair<int, int>> card;
	rep(i,n*m){
		int a, b;
		cin >> a >> b;
		--a;--b;
		card.emplace_back(a,b);
		flg[b][a] = true;
		if(!st[b].empty()) continue;
		for(int j=a-4;j<=a;j++){
			bool ok = true;
			for(int k=0;k<5;k++){
				if(j+k>=n) {
					ok = false;
					break;
				}
				if(!flg[b][j+k]) ok = false;
			}
			if(ok){
				for(int k=j;k<j+5;k++){
					st[b].insert(k);
				}
			}
		}
		bool ok = true;
		for(int j=n-4;j<n;j++) if(!flg[b][a]) ok = false;
		if(!flg[b][0]) ok = false;
		if(ok){
			for(int j=n-4;j<n;j++){
				st[b].insert(j);
			}
			st[b].insert(0);
		}
	}
	dbg(st);
	int ans = n*m;
	rep(i,m){
		int tmp = 0;
		int cnt = 0;
		queue<pair<int, int>> hand;
		rep(j,5) hand.emplace(card[j]);
		int now = 5;
		dbg(hand);
		while(now!=n*m){
			while(!hand.empty()){
				auto [a, b] = hand.front();hand.pop();
				if(i==b && st[i].count(a)) cnt++;
				dbg(a, b);
			}
			dbg(cnt, tmp);
			if(cnt==5){
				ans = min(ans, tmp);
				break;
			}
			for(int j=now;j<min(n*m,now+5-cnt);j++){
				hand.emplace(card[j]);
			}
			now += 5 - cnt;
			now = min(now, n*m-1);
			dbg(now);
			tmp++;
		}
	}

	cout << ans << endl;
	return 0;
}
0