結果
| 問題 |
No.2402 Dirty Stairs and Shoes
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-04 21:31:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 1,341 bytes |
| コンパイル時間 | 2,174 ms |
| コンパイル使用メモリ | 216,744 KB |
| 最終ジャッジ日時 | 2025-02-15 22:25:20 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
return (ull)rng() % B;
}
inline double time() {
return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n,k; cin >> n >> k;
vector<int> a(n+1, -1);
int m; cin >> m;
for (int i = 0; i < m; ++i) {
int b; cin >> b;
a[b] = 1;
}
cin >> m;
for (int i = 0; i < m; ++i) {
int b; cin >> b;
a[b] = 0;
}
vector<vector<int>> dp(2, vector<int>(n+1));
dp[0][0] = 1;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 2; ++j) {
if (!dp[j][i]) continue;
{
int nxt = j;
if (a[i+1] != -1) nxt = a[i+1];
dp[nxt][i+1] = 1;
}
if (i+k <= n) {
int nxt = j;
if (a[i+k] != -1) nxt = a[i+k];
dp[nxt][i+k] = 1;
}
}
}
if (dp[0][n]) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}