結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー KoseTKoseT
提出日時 2023-08-04 21:35:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 203,212 KB
実行使用メモリ 14,612 KB
最終ジャッジ日時 2023-08-23 01:40:53
合計ジャッジ時間 3,664 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 18 ms
8,648 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 29 ms
14,068 KB
testcase_06 AC 10 ms
6,176 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 7 ms
5,440 KB
testcase_09 AC 11 ms
7,532 KB
testcase_10 AC 17 ms
8,864 KB
testcase_11 AC 10 ms
5,880 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 12 ms
9,892 KB
testcase_14 AC 19 ms
14,612 KB
testcase_15 AC 11 ms
9,920 KB
testcase_16 AC 6 ms
5,632 KB
testcase_17 AC 14 ms
11,432 KB
testcase_18 AC 11 ms
9,276 KB
testcase_19 AC 17 ms
13,332 KB
testcase_20 AC 14 ms
11,432 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 8 ms
7,268 KB
testcase_23 AC 8 ms
6,680 KB
testcase_24 AC 8 ms
7,000 KB
testcase_25 AC 16 ms
13,008 KB
testcase_26 AC 8 ms
7,596 KB
testcase_27 AC 17 ms
13,464 KB
testcase_28 AC 12 ms
10,228 KB
testcase_29 AC 8 ms
7,328 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 17 ms
13,616 KB
testcase_32 AC 7 ms
7,064 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 6 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int m1;
  cin >> m1;
  vector<int> dirty(n+1, 0);
  for (int i=0;i<m1;++i) {
    int tmp; cin >> tmp;
    dirty[tmp] = 1;
  }
  int m2;
  cin >> m2;
  vector<int> wipe(n+1, 0);
  for (int i=0;i<m2;++i) {
    int tmp; cin >> tmp;
    wipe[tmp] = 1;
  }

  vector<vector<int>> dp(n+1, vector<int>(2, 0));
  dp[0][0] = 1;
  for (int i=0;i<n;++i) {
    if (dirty[i] == 1) {
      if (dp[i][0] == 1) dp[i][1] = 1;
      dp[i][0] = 0;
    }
    if (wipe[i] == 1) {
      if (dp[i][1] == 1) dp[i][0] = 1;
      dp[i][1] = 0;
    }
    if (dp[i][0] == 1) {
      if (i + k <= n) dp[i+k][0] = 1;
      dp[i+1][0] = 1;
    }
    if (dp[i][1] == 1) {
      if (i + k <= n)  dp[i+k][1] = 1;
      dp[i+1][1] = 1;
    }
  }
  if (dp[n][0] == 1) cout << "Yes\n";
  else cout << "No\n";
}
0