結果

問題 No.2402 Dirty Stairs and Shoes
コンテスト
ユーザー ortogawa
提出日時 2025-07-25 11:15:41
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 17 ms / 2,000 ms
+ 436µs
コード長 680 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,135 ms
コンパイル使用メモリ 215,184 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2026-07-13 11:35:36
合計ジャッジ時間 3,404 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#define int ll
#define fast_io cin.tie(0)->sync_with_stdio(0);
#define endl '\n'
typedef long long ll;

int32_t main() {
	fast_io;
	int n, k;
	cin >> n >> k;

	vector dp(n + 1, vector(2, 0));
	vector<int> tp(n + 1, 0);
	int m1; cin >> m1;
	while (m1--) {
		int x; cin >> x; tp[x] = 1;
	}
	int m2; cin >> m2;
	while (m2--) {
		int x; cin >> x; tp[x] = 2;
	}

	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int x : {0, 1}) {
			for (int j : {i + 1, i + k}) if (j <= n) {
				int nx = x;
				if (tp[j] == 1) nx = 1;
				if (tp[j] == 2) nx = 0;
				dp[j][nx] |= dp[i][x];
			}
		}
	}

	cout << (dp[n][0] ? "Yes" : "No") << endl;
}
0