Submission #142901

#TimeUsernameProblemLanguageResultExecution timeMemory
142901IC_COLDSTOPFibonacci representations (CEOI18_fib)C++17
15 / 100
15 ms504 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 cur=0, lst=0; for(auto IT=mp.begin(); IT!=mp.end();){ auto u=(*IT); cnt=u.F; while(mp[cnt] && mp[cnt+1]) mp[u.F]--, mp[u.F+1]--, mp[u.F+2]++; if(mp[u.F]>1){ if(cnt==1){ while(mp[cnt]>1) mp[cnt]-=2, mp[cnt+1]++; IT++; continue; } else if(cnt==2){ mp[cnt]--; mp[cnt-1]+=2; IT--; } else{ mp[cnt]--; mp[cnt-1]++; mp[cnt-2]++; IT--; IT--; IT--; } } else IT++; } cnt=0; dp[cur++][1]=1; for(auto u:mp) if(u.S){ //cout<<i<<" "<<u.F<<" "<<u.S<<endl; 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...