# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
943155 | 2024-03-11T08:47:04 Z | vjudge1 | Fibonacci representations (CEOI18_fib) | C++17 | 4000 ms | 1364 KB |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; vector <int> Delete(vector <int> v, int j) { vector <int> res; for (int i = 0; i < v.size(); i++) { if (i == j) continue; res.push_back(v[i]); } return res; } int main() { int n; cin >> n; vector <int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } vector <int> vec; for (int i = 1; i <= n; i++) { vec.push_back(a[i]); while (true) { sort(vec.begin(), vec.end()); if (vec.size() > 1 && vec[0] == vec[1] && vec[0] == 1) { vec.push_back(2); vec = Delete(vec, 1); vec = Delete(vec, 0); continue; } bool repeat = 0; for (int i = 1; i < vec.size(); i++) { if (vec[i] == vec[i - 1] + 1) { vec.push_back(vec[i] + 1); vec = Delete(vec, i); vec = Delete(vec, i - 1); repeat = 1; break; } } if (!repeat) break; } sort(vec.begin(), vec.end()); int sz = (int)vec.size(); int dp[sz][2]; dp[0][0] = 1; dp[0][1] = (vec[0] - 1) / 2; for (int i = 1; i < sz; i++) { if (vec[i - 1] != vec[i]) dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod; else dp[i][0] = dp[i - 1][1]; dp[i][1] = (1ll * ((vec[i] - 1 - vec[i - 1]) / 2) * dp[i][0]) % mod; if (vec[i - 1] % 2 == vec[i] % 2) { dp[i][1] += dp[i - 1][1]; dp[i][1] %= mod; } } cout << (dp[sz - 1][0] + dp[sz - 1][1]) % mod << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 504 KB | Output is correct |
2 | Execution timed out | 4018 ms | 1364 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |