Submission #1123748

#TimeUsernameProblemLanguageResultExecution timeMemory
1123748wikidereBinaria (CCO23_day1problem1)C++20
0 / 25
1 ms320 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)

Main.cpp: In function 'int main()':
Main.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:39:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...