Submission #136803

#TimeUsernameProblemLanguageResultExecution timeMemory
136803MinnakhmetovFibonacci representations (CEOI18_fib)C++14
0 / 100
4 ms508 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define all(aaa) aaa.begin(), aaa.end() const int N = 1005, MOD = 1e9 + 7; int dp[N][3][3], a[N]; int calc() { memset(dp, 0, sizeof(dp)); a[2] += a[1] / 2; a[1] %= 2; for (int i = 1; i < N - 1; i++) { int x = min(a[i], a[i - 1]); a[i] -= x; a[i - 1] -= x; a[i + 1] += x; } dp[N - 1][0][0] = 1; for (int i = N - 1; i > 0; i--) { for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { if (a[i] + y > 2) break; for (int k = 0; k <= a[i] + y; k++) { if (a[i] + y - k < 2 && x + k < 3) { dp[i - 1][k][x + k] = (dp[i - 1][k][x + k] + dp[i][x][y]) % MOD; } } } } } return dp[0][0][0]; return 0; } signed main() { #ifdef HOME freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; a[x]++; cout << calc() << "\n"; } return 0; }
#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...