Submission #290894

#TimeUsernameProblemLanguageResultExecution timeMemory
290894groeneprofFibonacci representations (CEOI18_fib)C++14
15 / 100
4050 ms6816 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...