Language: C++

#include <bits/stdc++.h>

using namespace std;
const int mod = 1e9 + 7;
int n;
int h[200];
int mypow(int x, int n) {
    if (n == 0) return 1;
    int g = mypow(x, n / 2);
    g = 1ll * g * g % mod;
    if (n & 1) g = 1ll * g * x % mod;
    return g;
}
int f[200][200];
int good[5][5];
long long geomprog(int b, int k) {
    return mypow(b, k + 1) - 1;
}
int solve(int l, int r) {
    for (int j = l; j <= r; j++) b[j] = a[j];
    sort(b + l, b + r + 1);
    int c = 1, k = 0;
    for (int i = l; i <= r; i++) {
        if (b[i] != b[i - 1]) {
            k++;
            l[k] = c;
            r[k] = b[i] - 1;
            c = b[i];
        }
    }
    f[l][0] = 2;
    for (int j = 1; j <= k; j++) {
        if (r[j] < a[l]) f[l][j] = (geomprog(2, a[j] - l[j]) - geomprog(2, a[j] - r[j]) + mod) % mod;
    for (int i = l; i < r; i++)
    for (int j = 0; j <= k; j++)
        if (f[i][j] != 0) {
            if (j == 0) {
                if (a[i] >= a[i + 1]) {
                    f[i + 1][0] += f[i][j];
                    if (f[i + 1][0] >= mod) f[i + 1][0] -= mod;
                }
            }
            else {
                if (r[j] < a[i + 1]) {
                    int c = 1;
                    if (a[i + 1] > a[i]) c = mypow(2, a[i + 1] - a[i]);
                    f[i + 1][j] += 1ll * f[i][j] * c % mod;
                    if (f[i + 1][j] >= mod) f[i + 1][j] -= mod;
                }
                else {
                    f[i + 1][0] += f[i][j];
                    if (f[i + 1][0] >= mod) f[i + 1][0] -= mod;
                }
            }
        }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    good[0][3] = good[3][0] = 1;
    good[1][2] = good[2][1] = 1;
    good[1][1] = good[2][2] = 1;
    for (int i = 1; i <= n; i++) cin >> h[i];
    long long c = 1; int prv = 0;
    h[n + 1] = 1;
    for (int i = 1; i <= n + 1; i++) {
        if (h[i] == 1) {
            if (i != n + 1) c = c * 2 % mod;
            if (prv + 1 <= i - 1) c = c * solve(prv + 1, i - 1) % mod;
            prv = i;
        }
    }
    cout << c << "\n";
    return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:20:34: error: 'b' was not declared in this scope
   20 |     for (int j = l; j <= r; j++) b[j] = a[j];
      |                                  ^
a.cc:20:41: error: 'a' was not declared in this scope
   20 |     for (int j = l; j <= r; j++) b[j] = a[j];
      |                                         ^
a.cc:21:10: error: 'b' was not declared in this scope
   21 |     sort(b + l, b + r + 1);
      |          ^
a.cc:26:14: error: invalid types 'int[int]' for array subscript
   26 |             l[k] = c;
      |              ^
a.cc:27:14: error: invalid types 'int[int]' for array subscript
   27 |             r[k] = b[i] - 1;
      |              ^
a.cc:33:14: error: invalid types 'int[int]' for array subscript
   33 |         if (r[j] < a[l]) f[l][j] = (geomprog(2, a[j] - l[j]) - geomprog(2, a[j] - r[j]) + mod) % mod;
      |              ^
a.cc:33:20: error: 'a' was not declared in this scope
   33 |         if (r[j] < a[l]) f[l][j] = (geomprog(2, a[j] - l[j]) - geomprog(2, a[j] - r[j]) + mod) % mod;
      |                    ^
a.cc:33:57: error: invalid types 'int[int]' for array subscript
   33 |         if (r[j] < a[l]) f[l][j] = (geomprog(2, a[j] - l[j]) - geomprog(2, a[j] - r[j]) + mod) % mod;
      |                                                         ^
a.cc:33:84: error: invalid types 'int[int]' for array subscript
   33 |         if (r[j] < a[l]) f[l][j] = (geomprog(2, a[j] - l[j]) - geomprog(2, a[j] - r[j]) + mod) % mod;
      |                                                                                    ^
a.cc:38:21: error: 'a' was not declared in this scope
   38 |                 if (a[i] >= a[i + 1]) {
      |                     ^
a.cc:44:22: error: invalid types 'int[int]' for array subscript
   44 |                 if (r[j] < a[i + 1]) {
      |                      ^
a.cc:44:28: error: 'a' was not declared in this scope
   44 |                 if (r[j] < a[i + 1]) {
      |                            ^
a.cc:57:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   57 | int main() {
      |         ^~
a.cc:57:9: note: remove parentheses to default-initialize a variable
   57 | int main() {
      |         ^~
      |         --
a.cc:57:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:57:12: error: a function-definition is not allowed here before '{' token
   57 | int main() {
      |            ^
a.cc:75:2: error: expected '}' at end of input
   75 | }
      |  ^
a.cc:19:25: note: to match this '{'
   19 | int solve(int l, int r) {
      |                         ^
a.cc:75:2: warning: no return statement in function returning non-void [-Wreturn-type]
   75 | }
      |  ^