Submission #1028186

# Submission time Handle Problem Language Result Execution time Memory
1028186 2024-07-19T14:57:40 Z vjudge1 Fibonacci representations (CEOI18_fib) C++17
0 / 100
198 ms 432 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int N = 1e2+2, mod = 1e9+7;

int n, a[N], b[N], f[N], dp[2][N];

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  f[1] = 1;
  f[2] = 2;
  for (int i = 3; i < N; i++) {
    f[i] = (f[i-1] + f[i-2]) % mod;
  }

  for (int i = 0; i < n; i++) {
    b[i] = a[i];
    sort(b, b+i+1);
  
    for (int j = 0; j <= i; j++) {
      dp[0][j] = dp[1][j] = 0;

      // puedo coger desde b[j]
      int sz = b[j] - (j ? b[j-1] : 0) - 1;
      dp[0][j] += (1 + sz/2) * (j ? dp[0][j-1] : 1) % mod;
      dp[0][j] %= mod;

      if (j) {
        sz++;
        dp[0][j] += (1 + sz/2) * dp[1][j-1] % mod;
        dp[0][j] %= mod;
      }

      // puedo coger desde b[j]-1
      sz = b[j] - (j ? b[j-1] : 0) - 1;
      dp[1][j] += (sz/2) * (j ? dp[0][j-1] : 1) % mod;
      dp[1][j] %= mod;

      if (j) {
        sz++;
        dp[1][j] += (sz/2) * dp[1][j-1] % mod;
        dp[1][j] %= mod;
      }
    }

    cout << dp[0][i] << "\n";
  }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 198 ms 432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -