Language: Java

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, m, psa[200][200], dp[18][200][200][200];
char ch;
int32_t main(){
  scanf("%i%i", &n, &m);
  fox1(l, n){
    fox1(l2, m){
      scanf(" %c", &ch);
      psa[l][l2] = (ch=='#')+psa[l][l2-1];
      //psa2[l][l2] = (ch=='#')+psa[l-1][l2];
    }
  }
  flood(dp);
  fox1(l, n){
    fox1(l2, m){
      for(int l3 = l2; l3 <= m; ++l3){
        if (psa[l][l3] - psa[l][l2-1] == 0 || psa[l][l3] - psa[l][l2-1] == l3-l2+1){
          if (psa[l][l3] - psa[l][l3-1] != psa[l-1][l3] - psa[l][l3-1] || l == 1){
            dp[0][l][l2][l3] = l;
          } else {
            dp[0][l][l2][l3] = dp[0][l-1][l2][l3];
          }
        } else {
          dp[0][l][l2][l3] = l+1;
        }
      }
    }
  }
  fox(t, 19){
    /*cout << t << endl;
    fox1(l, n){
      fox1(l2, m){
        fox1(l3, m){
          printf("%i %i %i\n", l2, l3, dp[t][l][l2][l3]);
        }
      }
      printf("\n");
    }*/
    if (dp[t][n][1][m] <= 1){
      cout << t;
      return 0;
    }
    fox1(l, n){
      fox1(l2, m){
        int p = 1;
        for (int l3 = m; l3 >= l2; --l3){
          while(p <l2 && dp[t][l][p][l2-1] > dp[t][l][l2][l3]) ++p;
          dp[t+1][l][p][l3] = min(dp[t+1][l][p][l3], dp[t][l][l2][l3]);
        }
      }
      fox1(l2, m){
        int p = m;
        for (int l3 = 1; l3 <= l2; ++l3){
          while(p > l2 && dp[t][l][l2+1][p] > dp[t][l][l3][l2]) --p;
          dp[t+1][l][l3][p] = min(dp[t+1][l][l3][p], dp[t][l][l3][l2]);
        }
      }
      fox1(l2, m){
        for (int l3 = l2; l3 <= m; ++l3){
          if (dp[t][l][l2][l3] == 1) dp[t+1][l][l2][l3] = 1;
          else dp[t+1][l][l2][l3] = min(dp[t+1][l][l2][l3], dp[t][dp[t][l][l2][l3]-1][l2][l3]);
        }
      }
    }
  }
  return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:3: error: illegal character: '#'
#define ll long long
^
Main.java:3: error: class, interface, enum, or record expected
#define ll long long
        ^
Main.java:4: error: illegal character: '#'
#define mp make_pair
^
Main.java:5: error: illegal character: '#'
#define pb push_back
^
Main.java:6: error: illegal character: '#'
#define x first
^
Main.java:7: error: illegal character: '#'
#define y second
^
Main.java:8: error: illegal character: '#'
#define pii pair<int, int>
^
Main.java:9: error: illegal character: '#'
#define p3i pair<pii, int>
^
Main.java:10: error: illegal character: '#'
#define pll pair<ll, ll>
^
Main.java:11: error: illegal character: '#'
#define p3l pair<pll, ll>
^
Main.java:12: error: illegal character: '#'
#define vi vector<int>
^
Main.java:13: error: illegal character: '#'
#define vpii vector<pii>
^
Main.java:14: error: illegal character: '#'
#define vp3i vector<p3i>
^
Main.java:15: error: illegal character: '#'
#define vpll vector<pll>
^
Main.java:16: error: illegal character: '#'
#define vp3l vector<p3l>
^
Main.java:17: error: illegal character: '#'
#define lseg L, (L+R)/2, N*2+1
^
Main.java:18: error: illegal character: '#'
#define rseg (L+R)/2+1, R, N*2+2
^
Main.java:19: error: illegal character: '#'
#define ub upper_bound
^
Main.java:20: error: illegal character: '#'
#define lb lower_bound
^
Main.java:21: error: illegal character: '#'
#define pq priority_queue
^
Main.java:22: error: illegal character: '#'
#define MN 1000000007
^
Main.java:23: error: illegal character: '#'
#define fox(k, x) for (int k=0; k<x; ++k)
^
Main.java:23: error: class, interface, enum, or record expected
#define fox(k, x) for (int k=0; k<x; ++k)
                                ^
Main.java:23: error: class, interface, enum, or record expected
#define fox(k, x) for (int k=0; k<x; ++k)
                                     ^
Main.java:24: error: illegal character: '#'
#define fox1(k, x) for (int k=1; k<=x; ++k)
^
Main.java:24: error: class, interface, enum, or record expected
#define fox1(k, x) for (int k=1; k<=x; ++k)
                                 ^
Main.java:24: error: class, interface, enum, or record expected
#define fox1(k, x) for (int k=1; k<=x; ++k)
                                       ^
Main.java:25: error: illegal character: '#'
#define foxr(k, x) for (int k=x-1; k>=0; --k)
^
Main.java:25: error: class, interface, enum, or record expected
#define foxr(k, x) for (int k=x-1; k>=0; --k)
                                   ^
Main.java:25: error: class, interface, enum, or record expected
#define foxr(k, x) for (int k=x-1; k>=0; --k)
                                         ^
Main.java:26: error: illegal character: '#'
#define fox1r(k, x) for (int k=x; k>0; --k)
^
Main.java:26: error: class, interface, enum, or record expected
#define fox1r(k, x) for (int k=x; k>0; --k)
                                  ^
Main.java:26: error: class, interface, enum, or record expected
#define fox1r(k, x) for (int k=x; k>0; --k)
                                       ^
Main.java:27: error: illegal character: '#'
#define ms multiset
^
Main.java:28: error: illegal character: '#'
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
^
Main.java:29: error: illegal character: '#'
#define drain(x) memset(x, 0, sizeof x)
^
Main.java:30: error: illegal character: '#'
#define rng() ((rand() << 14)+rand())
^
Main.java:31: error: illegal character: '#'
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
^
Main.java:31: error: class, interface, enum, or record expected
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
                                             ^
Main.java:31: error: class, interface, enum, or record expected
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
                                                         ^
Main.java:31: error: class, interface, enum, or record expected
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
                                                                             ^
Main.java:31: error: class, interface, enum, or record expected
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
                                                                                                    ^
Main.java:33: error: illegal character: '#'
#define pi 3.14159265358979323846
^
Main.java:33: error: class, interface, enum, or record expected
#define pi 3.14159265358979323846
        ^
Main.java:36: error: unnamed classes are a preview feature and are disabled by default.
char ch;
^
  (use --enable-preview to enable unnamed classes)
Main.java:73: error: not a statement
      cout << t;
           ^
Main.java:38: error: illegal start of expression
  scanf("%i%i", &n, &m);
                ^
Main.java:38: error: illegal start of expression
  scanf("%i%i", &n, &m);
                    ^
Main.java:39: error: ';' expected
  fox1(l, n){
            ^
Main.java:40: error: ';' expected
    fox1(l2, m){
               ^
Main.java:41: error: illegal start of expression
      scanf(" %c", &ch);
                   ^
Main.java:47: error: ';' expected
  fox1(l, n){
            ^
Main.java:48: error: ';' expected
    fox1(l2, m){
               ^
Main.java:62: error: ';' expected
  fox(t, 19){
            ^
Main.java:76: error: ';' expected
    fox1(l, n){
              ^
Main.java:77: error: ';' expected
      fox1(l2, m){
                 ^
Main.java:84: error: ';' expected
      fox1(l2, m){
                 ^
Main.java:91: error: ';' expected
      fox1(l2, m){
                 ^
60 errors