結果
問題 | No.1242 高橋君とすごろく |
ユーザー |
![]() |
提出日時 | 2024-04-08 18:56:32 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 2,428 ms |
コンパイル使用メモリ | 205,220 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 10:28:02 |
合計ジャッジ時間 | 2,646 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int main(){cin.tie(nullptr);ios_base::sync_with_stdio(false);//最大で12マス空けるように圧縮ll p=1, A, K, N, M, L=1;cin >> N >> K;vector<ll> ng2;//dp(i)=iから始めて出目に関わらずNに行けるか?for (int i=1; i<=K; i++){cin >> A;//p+1~AM = min(A-p, 13LL);L += M;ng2.push_back(L);p = A;}M = min(N-p, 13LL);L += M;vector<bool> dp(L+6);vector<bool> ng(L+6);for (auto x : ng2) ng[x] = 1;for (int i=L; i<=L+5; i++) dp[i] = 1;for (int i=L-1; i>=1; i--){if (ng[i]) continue;dp[i] = 1;for (int j=1; j<=6; j++){if (!dp[i+j] && !dp[i+(7-j)]) dp[i] = 0;}}cout << (dp[1] ? "Yes" : "No") << endl;return 0;}