Submission #142898

#TimeUsernameProblemLanguageResultExecution timeMemory
142898IC_COLDSTOPFibonacci representations (CEOI18_fib)C++17
15 / 100
11 ms632 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define int ll #define MP make_pair #define pb push_back #define F first #define S second #define REP(i,a,b) for(int i=a; i<b; i++) #define pii pair<int,int> const int MX=2e2+3, mod=1e9+7; int n, dp[MX][2]; map <int,int> mp; int32_t main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n; REP(i,0,n){ memset(dp, 0, sizeof dp); int cnt; cin>>cnt; if(cnt==1 && mp.find(1)!=mp.end()) mp[1]--, cnt++; mp[cnt]++; int flg=0, cur=0, lst=0; for(auto u:mp){ if(u.S && mp[u.F+1]) mp[u.F]--, mp[u.F+1]--, mp[u.F+2]++; if(mp[u.F]>1) flg=1; } if(flg){ cout<<0<<endl; continue; } dp[cur++][1]=1; for(auto u:mp) if(u.S){ cnt=u.F-lst; if(cnt%2==0){ dp[cur][1]=(dp[cur-1][0]+dp[cur-1][1])%mod; dp[cur][0]=(dp[cur-1][0]*(cnt/2)%mod+dp[cur-1][1]*(cnt/2-1)%mod)%mod; } else{ dp[cur][0]=(dp[cur-1][0]+dp[cur-1][1])*(cnt/2)%mod; dp[cur][1]=(dp[cur-1][0]+dp[cur-1][1])%mod; } cur++; lst=u.F; } cout<<(dp[cur-1][0]+dp[cur-1][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...