Submission #3411531


Source Code Expand

#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, X, Y, Z;
    cin >> N >> X >> Y >> Z;

    constexpr ll MOD = (ll)1e9 + 7;
    const ll MAX = 1LL << (X + Y + Z - 1);

    //XYZを含む⇔符号化するとX + Y + Z - 1個目, Y + Z - 1個目, Z - 1個目のビットが立っている
    const ll NG_BITS = (1LL << (X + Y + Z - 1)) | (1LL << (Y + Z - 1)) | (1LL << (Z - 1));

    //dp[i][j] := i番目まで見て,直前の数列を符号化したものがjであるときのXYZとなっていない数
    vector<vector<ll>> dp(N + 1, vector<ll>(MAX, 0));
    dp[0][0] = 1;

    for (ll i = 0; i < N; i++) {
        for (ll j = 1; j <= 10; j++) {
            for (ll k = 0; k < MAX; k++) {
                //k:前回までのbit列
                //遷移:kをjだけ左にシフトして、そこに先頭だけ1を立てたものを入れる
                ll t = (k << j) | (1LL << (j - 1));

                //XYZとなっているかの判定
                if ((NG_BITS & t) != NG_BITS) {
                    //上の方は関係ないのでマスクする
                    t &= (MAX - 1);

                    dp[i + 1][t] += dp[i][k];
                    dp[i + 1][t] %= MOD;
                }
            }
        }
    }

    //全ての数からXYZとならない数を引く
    ll ans = 1;
    for (ll i = 0; i < N; i++) {
        ans *= 10;
        ans %= MOD;
    }

    for (ll i = 0; i < MAX; i++) {
        ans += MOD - dp[N][i];
        ans %= MOD;
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task E - Iroha and Haiku
User tokumini
Language C++ (GCC 5.4.1)
Score 0
Code Size 1600 Byte
Status CE

Compile Error

./Main.cpp:3:7: error: expected nested-name-specifier before ‘ll’
 using ll = int64_t;
       ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:6:5: error: ‘ll’ was not declared in this scope
     ll N, X, Y, Z;
     ^
./Main.cpp:7:12: error: ‘N’ was not declared in this scope
     cin >> N >> X >> Y >> Z;
            ^
./Main.cpp:7:17: error: ‘X’ was not declared in this scope
     cin >> N >> X >> Y >> Z;
                 ^
./Main.cpp:7:22: error: ‘Y’ was not declared in this scope
     cin >> N >> X >> Y >> Z;
                      ^
./Main.cpp:7:27: error: ‘Z’ was not declared in this scope
     cin >> N >> X >> Y >> Z;
                           ^
./Main.cpp:9:5: error: ‘constexpr’ was not declared in this scope
     constexpr ll MOD = (ll)1e9 + 7;
     ^
./Main.cpp:10:11: error: ‘ll’ does not name a type
     const ll MAX = 1LL << (X + Y + Z - 1);
           ^
./Main.cpp:13:11: error: ‘ll’ does not name a type
     const ll NG_BITS = (1LL << (X + Y + Z - 1)) | (1LL << (Y + Z - 1)) | (1LL << (Z ...