結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー nystnyst
提出日時 2023-08-04 22:22:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 1,739 bytes
コンパイル時間 3,489 ms
コンパイル使用メモリ 190,364 KB
実行使用メモリ 30,504 KB
最終ジャッジ日時 2023-08-23 01:44:22
合計ジャッジ時間 6,948 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 110 ms
15,164 KB
testcase_04 AC 8 ms
4,932 KB
testcase_05 AC 158 ms
26,244 KB
testcase_06 AC 43 ms
9,988 KB
testcase_07 AC 17 ms
5,696 KB
testcase_08 AC 33 ms
8,256 KB
testcase_09 AC 54 ms
12,064 KB
testcase_10 AC 101 ms
15,968 KB
testcase_11 AC 51 ms
10,152 KB
testcase_12 AC 18 ms
5,680 KB
testcase_13 AC 80 ms
19,420 KB
testcase_14 AC 139 ms
30,504 KB
testcase_15 AC 35 ms
14,104 KB
testcase_16 AC 30 ms
9,052 KB
testcase_17 AC 99 ms
23,180 KB
testcase_18 AC 71 ms
18,092 KB
testcase_19 AC 119 ms
26,972 KB
testcase_20 AC 95 ms
22,916 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 47 ms
12,972 KB
testcase_23 AC 20 ms
8,892 KB
testcase_24 AC 47 ms
12,376 KB
testcase_25 AC 118 ms
26,464 KB
testcase_26 AC 47 ms
13,328 KB
testcase_27 AC 119 ms
27,580 KB
testcase_28 AC 83 ms
19,916 KB
testcase_29 AC 47 ms
13,076 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 121 ms
27,852 KB
testcase_32 AC 46 ms
12,528 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 35 ms
9,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cmath>
#include <bitset>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <tuple>
#include <atcoder/all>
#include <sstream> // std::stringstream
#include <regex>
#include <fstream>
using namespace atcoder;
using mint = modint998244353;
//using mint = modint1000000007;
using namespace std;
using ll = long long;
static const double pi = 3.141592653589793;
const int INF = (1 << 29);
const ll mod = 998244353;
// ifstream ifs(""); ファイルはワークスペースのトップにおく

int main() {

    int n,k;
    cin >> n >> k;
    int m1;cin >> m1;
    vector<int> a(m1);
    map<int,bool> mp;
    for(int i=0;i<m1;i++) {
        cin >> a[i];
        mp[a[i]] = true;
    }
    int m2;cin >> m2;
    vector<int> b(m2);
    map<int,bool> mp2;
    for(int i=0;i<m2;i++) {
        cin >> b[i];
        mp2[b[i]] = true;
    }
    vector dp(n+1,vector<int>(2,0));
    //dp[n][0 or 1] 靴が汚れているか

    dp[0][0] = true;
    for(int i=0;i<n;i++){
        if(dp[i][0]){
            if(i+1<=n) {
                if(mp[i+1]) dp[i+1][1] = true;
                else dp[i+1][0] = true;
            }
            if(i+k<=n){
                if(mp[i+k]) dp[i+k][1] = true;
                else dp[i+k][0] = true;
            }
        }
        if(dp[i][1]){
            if(i+1<=n){
                if(mp2[i+1]) dp[i+1][0] = true;
                else dp[i+1][1] = true;
            }
            if(i+k<=n){
                if(mp2[i+k]) dp[i+k][0] = true;
                else dp[i+k][1] = true;
            }
        }
    }

    if(dp[n][0]) cout << "Yes" << endl;
    else cout << "No" << endl;

} 
0