For this Question: Tom is currently playing in the park which is in the form of NxM grid. He is currently at (0,0) and wants to reach (N-1, M-1). If Tom is currently at (a,b), then after a move Tom can be at (a-1,b) or (a+1,b) or(a,b-1) or (a,b+1), provided any of these coordinates is not outside the park. 

You are given a matrix X of NxM size that tells us the contents of each cell.

If X[x1][y1] == X[x2][y2] then Tom can move from (x1,y1) to (x2,y2) without energy drinks.
If X[x1][y1] != X[x2][y2], then Tom can move from (x1,y1) to (x2,y2) by consuming a bottle of energy drink.

Find the minimum number of energy drinks that Tom must consume to reach (N-1,M-1) starting from (0,0).The input consists of two lines. 
The first line consists of two integers N and M representing the order of the park. The next N lines each contain M characters representing the map of the park.

<b>Constraints</b>
2 <= N <= 1000
2 <= M <= 1000
'a' <= X[i][j] <= 'z'Find the minimum number of energy drinks that Tom must consume to reach (N-1,M-1) starting from (0,0).Input
2 2
aa
aa

Output
0

Input
2 3
abc
def

Output
3, I have written this Solution Code: #include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e3 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

char c[N][N];
int dp[N][N];

signed main() {
	IOS;
	int n, m;	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> c[i][j], dp[i][j] = inf;
	int x[] = {-1, 1, 0, 0};
	int y[] = {0, 0, -1, 1};
	deque<pi> q;
	q.push_back({1, 1});
	dp[1][1] = 0;
	while(!q.empty()){
		pi p = q.front();
		q.pop_front();
		for(int i = 0; i < 4; i++){
			int nx = p.fi + x[i];
			int ny = p.se + y[i];
			if(nx <= 0 || ny <= 0 || nx > n || ny > m)
				continue;
			if(c[nx][ny] == c[p.fi][p.se] && dp[nx][ny] > dp[p.fi][p.se]){
				dp[nx][ny] = dp[p.fi][p.se];
				q.push_front({nx, ny});
			}
			if(c[nx][ny] != c[p.fi][p.se] && dp[nx][ny] > 1 + dp[p.fi][p.se]){
				dp[nx][ny] = 1 + dp[p.fi][p.se];
				q.push_back({nx, ny});
			}
		}
	}
	cout << dp[n][m];
	return 0;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?