結果
| 問題 | No.653 E869120 and Lucky Numbers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-08-18 11:13:46 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,217 bytes | 
| コンパイル時間 | 1,155 ms | 
| コンパイル使用メモリ | 85,044 KB | 
| 最終ジャッジ日時 | 2025-01-13 02:57:09 | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 WA * 1 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
std::vector<std::vector<int>> xss{{0}, {6, 7}, {12, 13, 14}};
void solve() {
    std::string n;
    std::cin >> n;
    std::reverse(n.begin(), n.end());
    // carry, remain
    auto dp = vec(2, vec(3, false));
    std::fill(dp[0].begin(), dp[0].end(), true);
    for (char cc : n) {
        int d = cc - '0';
        auto ndp = vec(2, vec(3, false));
        for (int c = 0; c <= 1; ++c) {
            for (int t = 0; t <= 2; ++t) {
                if (!dp[c][t]) continue;
                for (auto x : xss[t]) {
                    int s = x + c;
                    if (s % 10 != d) continue;
                    ndp[s / 10][t] = true;
                }
            }
        }
        std::swap(dp, ndp);
        for (int c = 0; c <= 1; ++c) {
            for (int t = 1; t >= 0; --t) {
                if (dp[c][t + 1]) dp[c][t] = true;
            }
        }
    }
    std::cout << (dp[0][0] ? "Yes" : "No") << "\n";
}
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}
            
            
            
        