結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー iwaiwaiwaispiwaiwaiwaisp
提出日時 2023-08-04 21:46:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 2,150 bytes
コンパイル時間 3,606 ms
コンパイル使用メモリ 228,992 KB
実行使用メモリ 13,708 KB
最終ジャッジ日時 2023-08-23 01:43:03
合計ジャッジ時間 5,306 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 32 ms
8,236 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 50 ms
13,316 KB
testcase_06 AC 16 ms
5,864 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 10 ms
5,436 KB
testcase_09 AC 17 ms
7,172 KB
testcase_10 AC 29 ms
8,544 KB
testcase_11 AC 18 ms
5,904 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 12 ms
9,692 KB
testcase_14 AC 18 ms
13,708 KB
testcase_15 AC 11 ms
9,332 KB
testcase_16 AC 6 ms
5,456 KB
testcase_17 AC 14 ms
10,872 KB
testcase_18 AC 11 ms
8,908 KB
testcase_19 AC 16 ms
12,468 KB
testcase_20 AC 13 ms
10,948 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 8 ms
7,084 KB
testcase_23 AC 7 ms
6,388 KB
testcase_24 AC 8 ms
6,792 KB
testcase_25 AC 16 ms
12,232 KB
testcase_26 AC 8 ms
6,956 KB
testcase_27 AC 16 ms
12,716 KB
testcase_28 AC 12 ms
9,668 KB
testcase_29 AC 8 ms
7,248 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 16 ms
12,788 KB
testcase_32 AC 7 ms
6,792 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 6 ms
5,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <atcoder/all>
#include <functional> 
using namespace atcoder;
using namespace std;

#define reps(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define repe(i,n) for(auto i : n)

#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による

#define F first
#define S second
#define ll long long

#define cYes cout << "Yes" << endl;
#define cNo cout << "No" << endl;

#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;
#define coutALL2d(vv) for(const auto& v : vv){for(const auto& e : v){cout << e << " ";}cout << endl;}
#define cout2(x,y) cout << x << " " << y << endl;
#define cout3(x,y,z) cout << x << " " << y << " " << z << endl;
#define cout4(x,y,z,p) cout << x << " " << y << " " << z <<" " << p << endl;

#define vmax(x) *max_element(x.begin(), x.end())
#define vmin(x) *min_element(x.begin(), x.end())

#define vi vector<int>
#define vvi vector<vector<int> >
#define vll vector<long long>
#define vvll vector<vector<long long> >

using namespace std;
using namespace atcoder;


int main() {
  int n,k,m1,m2;
  cin >> n >> k;
  cin >> m1;
  vi kai(n+1);
  rep(i,m1){
    int a;
    cin >> a;
    kai[a] = 1;
  }
  cin >> m2;
  rep(i,m2){
    int a;
    cin >> a;
    kai[a] = 2;
  }
  vvi dp(n+1,vi(2));
  dp[0][0] = 1;
  reps(i,1,n+1){
    if(kai[i] == 1 ){
      if(i-k >= 0){
        dp[i][1] = (dp[i-k][0] || dp[i-k][1]);
      }
      dp[i][1] |= (dp[i-1][0] || dp[i-1][1]);
    }
    else if(kai[i] == 2 ){
      if(i-k >= 0){
        dp[i][0] = (dp[i-k][0] || dp[i-k][1]);
      }
      dp[i][0] |= (dp[i-1][0] || dp[i-1][1]);
    }
    else{
      rep(j,2){
        if(i-k >= 0){
          dp[i][j] = dp[i-k][j];
        }
        dp[i][j] |= dp[i-1][j];    
      }
    }    
  }
  if(dp[n][0] == 1){
    cYes;
  }
  else{
    cNo;
  }
}
0