結果
問題 | No.2402 Dirty Stairs and Shoes |
ユーザー |
|
提出日時 | 2023-08-06 11:08:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 1,169 bytes |
コンパイル時間 | 1,998 ms |
コンパイル使用メモリ | 179,020 KB |
実行使用メモリ | 21,316 KB |
最終ジャッジ日時 | 2024-12-20 02:48:59 |
合計ジャッジ時間 | 3,659 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> #include <iterator> using namespace std; #define rep(i, n) for(int i=0; i<n; i++) #define debug 1 using ll = long long; using ld = long double; const int mod = 998244353; const double pi = atan2(0, -1); #include <time.h> #include <chrono> int main() { int N, K; cin >> N>>K; int M1; cin >> M1; set<int> A; rep(i, M1) { int a; cin >> a; A.insert(a); } int M2; cin >> M2; set<int> B; rep(i, M2) { int b; cin>>b; B.insert(b); } vector<vector<bool>> stair(N + 1, vector<bool>(2)); stair[0][0] = true; rep(i, N) { if (stair[i][0]) { if (A.count(i + 1)) { stair[i + 1][1] = true; } else { stair[i + 1][0] = true; } if (i + K <= N) { if (A.count(i + K)) { stair[i + K][1] = true; } else { stair[i + K][0] = true; } } } if (stair[i][1]) { if (B.count(i + 1)) { stair[i + 1][0] = true; } else { stair[i + 1][1] = true; } if (i + K <= N) { if (B.count(i + K)) { stair[i + K][0] = true; } else { stair[i + K][1] = true; } } } } if (stair[N][0]) { cout << "Yes" << endl; } else { cout << "No" << endl; } }