結果
問題 | No.2402 Dirty Stairs and Shoes |
ユーザー | cho435 |
提出日時 | 2023-08-04 22:12:52 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 120 ms / 2,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 5,885 ms |
コンパイル使用メモリ | 268,828 KB |
実行使用メモリ | 18,596 KB |
最終ジャッジ日時 | 2024-12-20 02:41:44 |
合計ジャッジ時間 | 6,516 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) int main(){ int n,k; cin>>n>>k; set<int> dl,st; int m; cin>>m; rep(i,m){ int a; cin>>a; dl.insert(a); } cin>>m; rep(i,m){ int b; cin>>b; st.insert(b); } vector<vector<int>> dp(n+1,vector<int>(2,0)); dp.at(0).at(0)=1; rep(i,n){ if(dp.at(i).at(0)){ if(dl.count(i)){ dp.at(i+1).at(1)=1; if(i+k<=n) dp.at(i+k).at(1)=1; }else{ dp.at(i+1).at(0)=1; if(i+k<=n) dp.at(i+k).at(0)=1; } } if(dp.at(i).at(1)){ if(st.count(i)){ dp.at(i+1).at(0)=1; if(i+k<=n) dp.at(i+k).at(0)=1; }else{ dp.at(i+1).at(1)=1; if(i+k<=n) dp.at(i+k).at(1)=1; } } } if(dp.at(n).at(0)) cout<<"Yes"<<endl; else cout<<"No"<<endl; }