Submission #726902

# Submission time Handle Problem Language Result Execution time Memory
726902 2023-04-19T13:56:30 Z hariaakas646 A Huge Tower (CEOI10_tower) C++17
45 / 100
436 ms 262144 KB
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define MP make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;

lli mod = 1e9 + 9;

int main()
{
    int n, d;
    scd(n);
    scd(d);
    vi vec(n);
    frange(i, n) scd(vec[i]);
    vector<vll> dp(1 << n, vll(n));
    frange(i, n)
    {
        dp[1 << i][i] = 1;
    }
    lli tot = 0;
    frange(i, 1 << n)
    {
        frange(j, n)
        {
            if (i & (1 << j))
            {
                frange(k, n)
                {
                    if (j == k)
                        continue;
                    if (i & (1 << k) && vec[k] - vec[j] <= d)
                    {
                        dp[i][j] = (dp[i][j] + dp[i ^ (1 << j)][k]) % mod;
                    }
                }
            }
        }
    }
    frange(i, n)
    {
        tot += dp[(1 << n) - 1][i];
        tot %= mod;
    }
    printf("%lld", tot);
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
tower.cpp:40:5: note: in expansion of macro 'scd'
   40 |     scd(n);
      |     ^~~
tower.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
tower.cpp:41:5: note: in expansion of macro 'scd'
   41 |     scd(d);
      |     ^~~
tower.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
tower.cpp:43:18: note: in expansion of macro 'scd'
   43 |     frange(i, n) scd(vec[i]);
      |                  ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 5076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 21844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 436 ms 94684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 5076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 21828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 149 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 153 ms 229148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 123 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4436 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 110 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 102 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 116 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 137 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 15148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -