結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー Fu_L
提出日時 2024-01-23 23:23:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,124 bytes
コンパイル時間 2,290 ms
コンパイル使用メモリ 199,652 KB
最終ジャッジ日時 2025-02-18 22:27:56
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    int n, k;
    cin >> n >> k;
    int m1;
    cin >> m1;
    set<int> a;
    rep(i, 0, m1) {
        int A;
        cin >> A;
        a.insert(A);
    }
    int m2;
    cin >> m2;
    set<int> b;
    rep(i, 0, m2) {
        int B;
        cin >> B;
        b.insert(B);
    }
    vector<bool> dp(n + 1, false);
    dp[0] = true;
    rep(i, 1, n + 1) {
        if(a.find(i) != a.end()) {
            dp[i] = false;
            continue;
        }
        if(b.find(i) != b.end()) {
            dp[i] = true;
            continue;
        }
        dp[i] = dp[i - 1];
        if(i - k >= 0) {
            dp[i] = dp[i] | dp[i - k];
        }
    }
    if(dp[n]) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}
0