답안 #290889

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290889 2020-09-04T14:20:28 Z groeneprof Fibonacci representations (CEOI18_fib) C++14
0 / 100
4000 ms 384 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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4062 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4051 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -