답안 #746544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
746544 2023-05-22T17:33:38 Z vjudge1 Fibonacci representations (CEOI18_fib) C++17
50 / 100
4000 ms 1428 KB
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<long long>now;
	now.push_back(0);
	vector<int>all(n);
	for(int i=0;i<n;i++){
		cin>>all[i];
	}
	for(int asd=0;asd<n;asd++){
		now.push_back(all[asd]);
		while(true){
			sort(now.begin(),now.end());
			int f=-1;
			for(int i=1;i<(int)now.size()-1;i++){
				if(now[i]==now[i+1]-1){
					f=i;
				}
			}
			if(f!=-1){
				vector<long long>fn;
				for(int i=0;i<(int)now.size();i++){
					if(i==f||i==f+1){
						continue;
					}
					fn.push_back(now[i]);
				}
				fn.push_back(now[f]+2);
				now=fn;
			}
			else{
				sort(now.begin(),now.end());
				int f=-1;
				for(int i=1;i<(int)now.size()-1;i++){
					if(now[i]==now[i+1]){
						f=i;
					}
				}
				if(f!=-1){
					vector<long long>fn;
					for(int i=0;i<(int)now.size();i++){
						if(i==f||i==f+1){
							continue;
						}
						fn.push_back(now[i]);
					}
					if(now[f]==1){
						fn.push_back(2);
					}
					else if(now[f]==2){
						fn.push_back(3);
						fn.push_back(1);
					}
					else{
						fn.push_back(now[f]+1);
						fn.push_back(now[f]-2);
					}
					now=fn;
				}
				else{
					break;
				}
			}
		}
		while(true){
			sort(now.begin(),now.end());
			int f=-1;
			for(int i=1;i<(int)now.size()-1;i++){
				if(now[i]==now[i+1]){
					f=i;
				}
			}
			if(f!=-1){
				vector<long long>fn;
				for(int i=0;i<(int)now.size();i++){
					if(i==f||i==f+1){
						continue;
					}
					fn.push_back(now[i]);
				}
				if(now[f]==1){
					fn.push_back(2);
				}
				else if(now[f]==2){
					fn.push_back(3);
					fn.push_back(1);
				}
				else{
					fn.push_back(now[f]+1);
					fn.push_back(now[f]-2);
				}
				now=fn;
			}
			else{
				break;
			}
		}
		vector<pair<long long,long long>>dp(asd+3);
		long long len=0;
		dp[0]=make_pair(1,0);
		for(int i=1;i<(int)now.size();i++){
			len=now[i]-now[i-1]-1;
			if((now[i-1]%2)!=(now[i]%2)){
				dp[i]=make_pair(dp[i-1].first+dp[i-1].second,(dp[i-1].first+dp[i-1].second)*(len/2));
			}
			else{
				dp[i]=make_pair(dp[i-1].first+dp[i-1].second,(dp[i-1].first+dp[i-1].second)*(len/2)+dp[i-1].second);
			}
			dp[i].first%=mod;
			dp[i].second%=mod;
		}
		long long res=dp[(int)now.size()-1].first+dp[(int)now.size()-1].second;
		res%=mod;
		cout<<res<<"\n";
	}	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 356 KB Output is correct
2 Execution timed out 4069 ms 1428 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Execution timed out 4069 ms 1428 KB Time limit exceeded
26 Halted 0 ms 0 KB -