結果
| 問題 | No.653 E869120 and Lucky Numbers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-02-21 12:14:45 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,073 bytes | 
| コンパイル時間 | 1,427 ms | 
| コンパイル使用メモリ | 138,528 KB | 
| 最終ジャッジ日時 | 2025-01-19 02:58:29 | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 WA * 8 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;
template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.length();
    if(n == 1 || (s.back() != '2' && s.back() != '3')){
        cout << "No\n";
        return 0;
    }
    reverse(begin(s), end(s));
    vector<vector<vector<bool>>> dp(n + 1, vector<vector<bool>>(2, vector<bool>(2)));
    dp[1][1][0] = true;
    for(int i = 1; i < n; ++i){
        int num = s[i] - '0';
        for(int j = 0; j < 2; ++j){
            if(dp[i][j][0]){
                for(int x = 6; x <= 7; ++x){
                    for(int y = 6; y <= 7; ++y){
                        if((x + y + j) % 10 == num){
                            dp[i + 1][(x + y + j) / 10][0] = true;
                        }
                    }
                    dp[i + 1][(x + j) / 10][1] = true;
                }
            }
            if(dp[i][j][1]){
                for(int x = 6; x <= 7; ++x){
                    if((x + j) % 10 == num){
                        dp[i + 1][(x + j) / 10][1] = true;
                    }
                }
            }
        }
    }
    cout << ((dp[n][0][0] || dp[n][0][1]) ? "Yes\n" : "No\n");
    
    return 0;
}
            
            
            
        