結果
| 問題 |
No.2402 Dirty Stairs and Shoes
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-06 05:03:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 1,417 bytes |
| コンパイル時間 | 2,021 ms |
| コンパイル使用メモリ | 172,680 KB |
| 実行使用メモリ | 14,772 KB |
| 最終ジャッジ日時 | 2024-12-20 02:48:54 |
| 合計ジャッジ時間 | 3,374 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
/**
* - Meet Brahmbhatt
* - Hard work always pays off
**/
#include"bits/stdc++.h"
using namespace std;
#ifdef MeetBrahmbhatt
#include "debug.h"
#else
#define dbg(...) 72
#endif
#define endl "\n"
#define int long long
const long long INF = 4e18;
void solve() {
int n, k;
cin >> n >> k;
int m1;
cin >> m1;
vector<int> S(n + 1);
for (int i = 0; i < m1; i++) {
int x;
cin >> x;
S[x] = 1;
}
int m2;
cin >> m2;
for (int i = 0; i < m2; i++) {
int x;
cin >> x;
S[x] = -1;
}
vector<vector<int>> dp(n + 1, vector<int>(2));
dp[0][0] = 1;
for (int i = 0; i < n; i++) {
for (int x : vector<int> {i + 1, i + k}) {
if (x <= n) {
for (int j = 0; j < 2; j++) {
if (!dp[i][j]) {
continue;
}
if (S[x] == 1) {
dp[x][1] = 1;
} else if (S[x] == -1) {
dp[x][0] = 1;
} else {
dp[x][j] = dp[i][j];
}
}
}
}
}
cout << (dp.back()[0] == 1 ? "Yes" : "No");
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(9);
int tt = 1;
// cin >> tt;
while (tt--) solve();
return 0;
}