답안 #142904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
142904 2019-08-12T06:28:56 Z IC_COLDSTOP Fibonacci representations (CEOI18_fib) C++17
15 / 100
15 ms 504 KB
#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;
ll 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;
		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[cnt]--, mp[cnt+1]--, mp[cnt+2]++;
			if(mp[cnt]>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-2]++;
					mp[cnt+1]++;
					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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Runtime error 15 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -