結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー ortogawa
提出日時 2025-07-25 11:15:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 680 bytes
コンパイル時間 2,270 ms
コンパイル使用メモリ 200,252 KB
実行使用メモリ 14,740 KB
最終ジャッジ日時 2025-07-25 11:15:46
合計ジャッジ時間 4,623 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#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