Submission #1055416

#TimeUsernameProblemLanguageResultExecution timeMemory
1055416HazardBinaria (CCO23_day1problem1)C++98
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int MOD = 1e6 + 3; int count_strings(int N, int K, vector<int>& sms) { int dp[N + 1][K + 1]; memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for (int i = 0; i < N; i++) { for (int j = 0; j <= K; j++) { if (i < K) { dp[i + 1][j + 1] += dp[i][j]; dp[i + 1][j] += dp[i][j]; } else { int target = sms[i - K + 1]; if (j >= target) { dp[i + 1][j - target + 1] += dp[i][j]; } dp[i + 1][j] += dp[i][j]; } dp[i + 1][j + 1] %= MOD; dp[i + 1][j] %= MOD; } } int ans = 0; for (int i = 0; i <= K; i++) { ans += dp[N][i]; ans %= MOD; } return ans; } int main() { int N, K; cin >> N >> K; vector<int> sms(N - K + 1); for (int i = 0; i < N - K + 1; i++) { cin >> sms[i]; } int ans = count_strings(N, K, sms); cout << ans << endl; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int count_strings(int, int, std::vector<int>&)':
Main.cpp:11:5: error: 'memset' was not declared in this scope
   11 |     memset(dp, 0, sizeof(dp));
      |     ^~~~~~
Main.cpp:4:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 |