結果
問題 |
No.2402 Dirty Stairs and Shoes
|
ユーザー |
![]() |
提出日時 | 2024-04-13 19:45:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 1,201 bytes |
コンパイル時間 | 2,246 ms |
コンパイル使用メモリ | 200,368 KB |
最終ジャッジ日時 | 2025-02-21 01:16:38 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n, k; cin >> n >> k; vector<bool> a(n + 1), b(n + 1); int m1; cin >> m1; for (int i = 0; i < m1; i++) { int x; cin >> x; a[x] = true; } int m2; cin >> m2; for (int i = 0; i < m2; i++) { int x; cin >> x; b[x] = true; } vector<vector<bool>> dp(n + 1, vector<bool>(2)); dp[0][0] = true; for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) { if (!dp[i][j]) { continue; } int nj = j; if (a[i + 1]) { nj = 1; } if (b[i + 1]) { nj = 0; } dp[i + 1][nj] = true; if (i + k <= n) { nj = j; if (a[i + k]) { nj = 1; } if (b[i + k]) { nj = 0; } dp[i + k][nj] = true; } } } cout << (dp[n][0] ? "Yes" : "No") << endl; }