# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1123784 | wikidere | Binaria (CCO23_day1problem1) | C++17 | 0 ms | 320 KiB |
#include <bits/stdc++.h>
#define N 1000010
#define task "task"
#define pii pair<int, int>
#define ll long long
using namespace std;
const int base = 1e6 + 3;
int n, k, a[N];
namespace sub1
{
int dp[1010][1 << 10] = {};
void solve()
{
for (int mask = 0; mask < (1 << k); mask++)
dp[1][mask] = (__builtin_popcount(mask) == a[1]);
for (int i = 2; i <= n - k; i++)
for (int mask1 = 0; mask1 < (1 << k); mask1++)
for (int mask2 = 0; mask2 < (1 << k); mask2++)
if ((mask2 >> 1) == (mask1 & ((1 << (k - 1)) - 1)))
if (__builtin_popcount(mask1) == a[i - 1] && __builtin_popcount(mask2) == a[i])
(dp[i][mask2] += dp[i - 1][mask1]) %= base;
int res = 0;
for (int mask = 1; mask < (1 << k); mask++)
(res += dp[n - k][mask]) %= base;
cout << res;
}
};
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen(task".inp", "r"))
{
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin >> n >> k;
for (int i = 1; i <= n - k + 1; i++)
cin >> a[i];
if (n <= 10 && k <= 10) sub1::solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |