結果

問題 No.653 E869120 and Lucky Numbers
ユーザー outlineoutline
提出日時 2021-02-21 12:16:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,092 bytes
コンパイル時間 1,505 ms
コンパイル使用メモリ 143,464 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2023-10-19 14:10:37
合計ジャッジ時間 2,662 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 7 ms
6,656 KB
testcase_29 AC 8 ms
6,656 KB
testcase_30 WA -
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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' && s.back() != '4')){
        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;
}
0