結果

問題 No.2463 ストレートフラッシュ
ユーザー kabipoyokabipoyo
提出日時 2023-09-08 22:09:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,651 bytes
コンパイル時間 4,243 ms
コンパイル使用メモリ 265,196 KB
実行使用メモリ 7,228 KB
最終ジャッジ日時 2023-09-08 22:09:45
合計ジャッジ時間 9,255 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 194 ms
5,620 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 264 ms
6,160 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 337 ms
6,912 KB
testcase_20 AC 340 ms
6,912 KB
testcase_21 AC 100 ms
6,952 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;

int main() {
	lint N, M;
	cin >> N >> M;
	vi v(N*M), w(N*M);
	rep(i, N*M) cin >> v[i] >> w[i];

	lint a=0, b=0, c=LINF, x, y, z;
	rep(i, N*M) v[i]--, w[i]--;
	rep(i, M) {
		vi t(N);
		b = -1;
		rep(j, N*M) {
			if (w[j] == i) {
				if (!v[j]) {
					repx(k, N-4, N+5) {
						t[k%N]++;
						if (t[k%N] == 5) {b = k%N; break;}
					}
				} else {
					repx(k, max((lint)0, v[j]-4), min(N+1, v[j]+5)) {
						t[k%N]++;
						if (t[k%N] == 5) {b = k%N; break;}
					}
				}
			}
			if (b != -1) break;
		}
		set<int> s;
		a = 0, x = 0;
		rep(j, N*M) {
			if (w[j] == i && v[j] >= b && v[j] <= (b+4)%N) s.insert(v[j]);
			x++;
			if (s.size() == 5) break;
			if (x == 5) {
				x -= 5-s.size();
				a++;
			}
		}
		chmin(c, a);
	}
	std::cout << c << '\n';
}
0