#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);
vector<long long>now;
now.push_back(0);
int n;
cin>>n;
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{
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";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
356 KB |
Output is correct |
2 |
Execution timed out |
4027 ms |
2316 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |