Language: C++

#include<bits/stdc++.h>
using namespace std;
 
// Optimization
 
//#pragma GCC optimize("O3")
#define endl '\n'
 
// Shortcut
 
#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)
 
// I/O & Debug
 
#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/
 
// Functions
 
//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());
 
// Data Structure
 
#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;
 
const int N = 1e2 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
 
int n, m;
bool a[N][N];
int b[N][N];
bool ck[N][N];
queue <pair <pii, int>> qu;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
 
void ff(int x, int y, bool c, int dis){
    ck[x][y] = 1;
    b[x][y] = dis;
    For(i, 0, 4){
        int tx = x + dx[i], ty = y + dy[i];
        if (tx < 1 || tx > n || ty < 1 || ty > m) continue;
        if (!ck[tx][ty] && a[tx][ty] == c){
            ff(tx, ty, c, dis);
        }
        else if (!ck[tx][ty] && a[tx][ty] != c){
            qu.push({{tx, ty}, dis + (c == 0))});
        }
    }
}
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    ForE(i, 1, n){
        ForE(j, 1, m){
            char c; cin >> c;
            a[i][j] = (c == '#');
        }
    }
    qu.push({{1, 1}, a[1][1]});
    while (!qu.empty()){
        auto t = qu.front(); qu.pop();
        if (ck[t.fi.fi][t.fi.se]) continue;
        ff(t.fi.fi, t.fi.se, a[t.fi.fi][t.fi.se], t.se);
    }
    int t = b[n][m];
    if (a[1][1] && a[n][m]) t++;
    cout << t / 2;
}

Compiler output:
a.cc: In function 'void ff(long long int, long long int, bool, long long int)':
a.cc:99:46: error: expected '}' before ')' token
   99 |             qu.push({{tx, ty}, dis + (c == 0))});
      |                     ~                        ^
a.cc:99:47: error: expected ';' before '}' token
   99 |             qu.push({{tx, ty}, dis + (c == 0))});
      |                                               ^
      |                                               ;
a.cc:99:48: error: expected primary-expression before ')' token
   99 |             qu.push({{tx, ty}, dis + (c == 0))});
      |                                                ^
a.cc: At global scope:
a.cc:102:1: error: expected declaration before '}' token
  102 | }
      | ^