This is the problem: ORAC — Hard Drive , and my code is attached below
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
#define speed() \
ios::sync_with_stdio(false); \
cin.tie(0)
#ifndef DEBUG
#define open(name) \
speed(); \
freopen(#name "in.txt", "r", stdin); \
freopen(#name "out.txt", "w", stdout)
#else
#define open(name) speed()
#endif
#define all(x) (x).begin(), (x).end()
#define _forI(var, start, end) for (int var = start; var < end; var++)
const int MOD = 1000;
vector<vi> dp;
int cr(int n, int blocks) {
if (blocks == 1) {
return 1;
}
if (dp[n][blocks] != -1) {
return dp[n][blocks];
}
int count = cr(n, blocks/2);
if (blocks >= 4) {
count = (count + cr(n, blocks / 4) + cr(n, blocks / 2 - blocks / 4)) % MOD;
}
dp[n][blocks] = count;
return count;
}
int main() {
open(drive);
int n, m;
cin >> n >> m;
dp.resize(n + 1, vi(1 << (n + 1), - 1));
int ans = cr(n, 1 << n);
cout << ans % m;
return 0;
}
i don’t get why it doesn’t work, i did get some test cases but there are also MLEs and wrong answers. Please help
Thanks