Submission #813132

# Submission time Handle Problem Language Result Execution time Memory
813132 2023-08-07T13:46:59 Z Vladden Fibonacci representations (CEOI18_fib) C++14
15 / 100
1 ms 304 KB
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 107;
typedef long long ll;
const ll MOD = 1e9+7;
int A[N],B[N];
ll dp[N][2]; // 0 - prev was not split, 1 - prev was split
ll X(int n){
	if (n<0){
		return 0;
	}
	return (n+1)/2;
}
ll solve(int &n){
	sort(A+1,A+1+n,greater<int>());
	int ptr = 0;
	for(int i = n;i>1;i-=1){
		if (A[i-1]==A[i]+1 || (A[i-1]<=1 && A[i]<=1)){
			A[i-1] += 1;
		}
		else{
			B[++ptr] = A[i];
		}
	}
	B[++ptr] = A[1];
	for(int i = 1;i<=ptr;i+=1){
		A[i] = B[i];
	}
	n = ptr;
	dp[0][0] = 1;
	for(int i = 1;i<=n;i+=1){
		dp[i][0] = (A[i-1]!=A[i]?dp[i-1][0]:0)+dp[i-1][1];
		dp[i][1] = dp[i-1][0]*X(A[i]-2-A[i-1])+dp[i-1][1]*X(A[i]-2-(A[i-1]-1));
		dp[i][0] %= MOD;
		dp[i][1] %= MOD;

	}
	return (dp[n][0]+dp[n][1])%MOD;
}
int main(){
	int n;
	cin>>n;
	int sz = 0;
	for(int i = 1;i<=n;i+=1){
		cin>>A[++sz];
		cout<<solve(sz)<<'\n';
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -