Submission #290894

# Submission time Handle Problem Language Result Execution time Memory
290894 2020-09-04T14:23:00 Z groeneprof Fibonacci representations (CEOI18_fib) C++14
15 / 100
4000 ms 6816 KB
#include <bits/stdc++.h>
#define int long long
#define P(a) do{if(debug) cout<<a<<endl;} while(false)
#define H(a) P(#a<<": "<<a)
#define FR(i,a,b) for(int i = (a); i<(b); i++)
#define F(i,n) FR(i,0,n)

const int debug = 0;
const int mod = 1e9+7;
using namespace std;
vector<vector<int> > dp;
vector<int> a;

int X(int siz, int offset){ //offset is either -a[siz] or -a[siz]+1, 
	H(siz); H(offset);
	H(offset+a[siz]);
	if(siz==1) return ((a[0]+offset+1)/2)%mod; 
	if(dp[siz][offset+a[siz]]!=-1) return dp[siz][offset+a[siz]];

	dp[siz][offset+a[siz]] = (X(siz-1,offset-(a[siz-1]+offset)) + X(siz-1,offset-(a[siz-1]+offset)+1) * (X(1, a[siz-1]+offset-a[0])-1))%mod;
	H(siz); H(offset);
	H(offset+a[siz]);
	H(dp[siz][offset+a[siz]]);
	P("exit");
	return dp[siz][offset+a[siz]];
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	//a.resize(n+1,0);
	dp.assign(n+5,vector<int> (2,-1));
	F(i,n){
		int aa;
		cin>>aa;
		a.push_back(aa);
		sort(a.rbegin(),a.rend());
		aa = a[i];
		dp.assign(n+5,vector<int> (2,-1));
		if(i==0) cout<<X(1,0)<<endl;
		else cout<<(X(i,-aa) + X(i,-aa+1) * (X(1,aa-a[0])-1))%mod<<endl;;
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Execution timed out 4050 ms 6816 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -