Submission #755918

# Submission time Handle Problem Language Result Execution time Memory
755918 2023-06-10T17:44:11 Z MohamedFaresNebili A Huge Tower (CEOI10_tower) C++14
45 / 100
963 ms 208480 KB
#include <bits/stdc++.h>

        using namespace std;

        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)) % MOD;
                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)) % MOD;
                res %= MOD;
            }
            cout << res % MOD << "\n";
        }







# Verdict Execution time Memory Grader output
1 Correct 41 ms 102800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 102860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 102828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 102868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 102892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 208 ms 102904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 963 ms 102892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 102892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 184 ms 102896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 121 ms 208444 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 121 ms 208364 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 132 ms 208400 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 126 ms 208348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 140 ms 208372 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 131 ms 208480 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 131 ms 208416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 131 ms 208392 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 127 ms 208448 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 208472 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 142 ms 208460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -