結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー momoyuumomoyuu
提出日時 2023-10-22 17:24:06
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 1,146 bytes
コンパイル時間 1,272 ms
コンパイル使用メモリ 112,168 KB
実行使用メモリ 18,724 KB
最終ジャッジ日時 2023-10-22 17:24:11
合計ジャッジ時間 4,457 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 73 ms
12,192 KB
testcase_04 AC 6 ms
4,372 KB
testcase_05 AC 113 ms
18,724 KB
testcase_06 AC 29 ms
7,968 KB
testcase_07 AC 11 ms
4,868 KB
testcase_08 AC 20 ms
6,120 KB
testcase_09 AC 33 ms
8,760 KB
testcase_10 AC 68 ms
11,664 KB
testcase_11 AC 36 ms
7,968 KB
testcase_12 AC 13 ms
5,064 KB
testcase_13 AC 22 ms
9,288 KB
testcase_14 AC 31 ms
13,444 KB
testcase_15 AC 15 ms
9,288 KB
testcase_16 AC 9 ms
5,592 KB
testcase_17 AC 26 ms
10,608 KB
testcase_18 AC 19 ms
8,760 KB
testcase_19 AC 30 ms
12,124 KB
testcase_20 AC 24 ms
10,608 KB
testcase_21 AC 3 ms
4,372 KB
testcase_22 AC 13 ms
6,912 KB
testcase_23 AC 9 ms
6,384 KB
testcase_24 AC 14 ms
6,648 KB
testcase_25 AC 26 ms
11,860 KB
testcase_26 AC 14 ms
7,176 KB
testcase_27 AC 28 ms
12,388 KB
testcase_28 AC 22 ms
9,552 KB
testcase_29 AC 14 ms
6,912 KB
testcase_30 AC 3 ms
4,372 KB
testcase_31 AC 31 ms
12,388 KB
testcase_32 AC 13 ms
6,912 KB
testcase_33 AC 2 ms
4,372 KB
testcase_34 AC 11 ms
5,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<set>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,k;
    cin>>n>>k;
    vector<vector<int>> dp(n+1,vector<int>(2,0));
    dp[0][0] = 1;
    int m;
    cin>>m;
    set<int> a;
    for(int i = 0;i<m;i++){
        int now;
        cin>>now;
        a.insert(now);
    }
    cin>>m;
    set<int> b;
    for(int i = 0;i<m;i++){
        int now;
        cin>>now;
        b.insert(now);
    }
    for(int i = 0;i<=n;i++){
        for(int j = 0;j<2;j++){
            if(dp[i][j]==0) continue;
            int nxt = i + 1;
            if(nxt<=n){
                int now = j;
                if(a.count(nxt)) now = 1;
                if(b.count(nxt)) now = 0;
                dp[nxt][now] = 1;
            }
            nxt = i + k;
            if(nxt<=n){
                int now = j;
                if(a.count(nxt)) now = 1;
                if(b.count(nxt)) now = 0;
                dp[nxt][now] = 1;
            }
        }
    }
    if(dp[n][0]) cout<<"Yes\n";
    else cout<<"No\n";
}
0