#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9+7;
set <int> s;
void add(int a)
{
if(a == -1) return;
if(a == 0) a++;
if(s.count(a+1)) s.erase(a+1), add(a+2);
else if(s.count(a-1)) s.erase(a-1), add(a+1);
else if(s.count(a)) s.erase(a), add(a-2), add(a+1);
else s.insert(a);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,dp[2]; cin >> n;
for(int i=1,a; i<=n; i++)
{
cin >> a; add(a);
int ls = 0; dp[0] = 1, dp[1] = 0;
for(auto x : s)
{
int v0 = (dp[0]+dp[1])%mod;
int v1 = ((dp[0]*(x-ls-1)/2)%mod+(dp[1]*(x-ls)/2)%mod)%mod;
dp[0] = v0, dp[1] = v1;
ls = x;
}
cout << (dp[0]+dp[1])%mod << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |