Submission #755914

# Submission time Handle Problem Language Result Execution time Memory
755914 2023-06-10T17:41:51 Z vjudge1 A Huge Tower (CEOI10_tower) C++17
40 / 100
1000 ms 262148 KB
#include <bits/stdc++.h>

        using namespace std;
        using ll = long long;

        #define int ll

        const int MOD = 1e9 + 9;

        int N, D, A[100], DP[(1 << 20) + 5][25];
        int solve(int mask, int last) {
            if(__builtin_popcount(mask) == N)
                return 1;
            if(DP[mask][last] != -1)
                return DP[mask][last];
            int res = 0;
            for(int l = 0; l < N; l++) {
                if(mask & (1 << l)) continue;
                if(A[l] > D + A[last]) continue;
                res += solve(mask | (1 << l), l);
                res %= MOD;
            }
            return DP[mask][last] = res % MOD;
        }

        int32_t main() {
            ios_base::sync_with_stdio(0);
            cin.tie(0); cout.tie(0);
            cin >> N >> D;
            memset(DP, -1, sizeof DP);
            for(int l = 0; l < N; l++) cin >> A[l];
            int res = 0;
            for(int l = 0; l < N; l++) {
                res += solve((1 << l), l);
                res %= MOD;
            }
            cout << res % MOD << "\n";
        }


# Verdict Execution time Memory Grader output
1 Correct 88 ms 205400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 205384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 205456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 205396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 205476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 266 ms 205476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 205384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 166 ms 205540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 314 ms 205504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 315 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 304 ms 262148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 322 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 328 ms 262148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 327 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 205388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 317 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 324 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 205456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 363 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 334 ms 262144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -