For this Question: Given a 2D screen, you are given the location of a pixel in the screen i.e. (x, y) and a color(K), your task is to replace color of the given pixel at (x, y) and all pixels connected to it with the given color K.

Two pixels are connected if these conditions satisfy:
1. They both must have same color
2. They share an edge or they are connected to a common pixel

Example:

{{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 0, 0, 1, 1, 0, 1, 1},
{1, 2, 2, 2, 2, 0, 1, 0},
{1, 1, 1, 2, 2, 0, 1, 0},
{1, 1, 1, 2, 2, 2, 2, 0},
{1, 1, 1, 1, 1, 2, 1, 1},
{1, 1, 1, 1, 1, 2, 2, 1},
 };

 x=4, y=4, color=3 

{{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 0, 0, 1, 1, 0, 1, 1}, 
{1, 3, 3, 3, 3, 0, 1, 0},
{1, 1, 1, 3, 3, 0, 1, 0},
{1, 1, 1, 3, 3, 3, 3, 0},
{1, 1, 1, 1, 1, 3, 1, 1},
{1, 1, 1, 1, 1, 3, 3, 1}, };

Note: Use zero- based indexing.The first line of each test case contains two integers N and M denoting the size of the matrix. Then in the next line are N*M space-separated values of the matrix. Then in the next line are three values x, y and K.

Constraints:
1 <= N, M <= 300
0 <= A[][] <= 100For each test case print the space- separated values of the new matrix.Input:
3 4
0 1 1 0 1 1 1 1 0 1 2 3
0 1 5

Output
0 5 5 0 5 5 5 5 0 5 2 3

Input
2 2
1 1 1 1
0 1 8

Output
8 8 8 8, I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;

#define pu push_back
#define fi first
#define se second
#define mp make_pair
#define int long long
#define pii pair<int,int>
#define mm (s+e)/2
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define sz 200000
int A[2000][2000];
int vis[2000][2000];
int dist[2000][2000];
int xa[8]={0,0,1,-1,1,1,-1,-1};
int ya[8]={1,-1,0,0,1,-1,1,-1};
int n,m;
int val,hh;
int check(int x,int y)
{
if (x>=0 && y>=0 && x<n && y<m && A[x][y]==val)return 1;
else return 0;
}
#define qw1 freopen("input1.txt", "r", stdin); freopen("output1.txt", "w", stdout);
#define qw2 freopen("input2.txt", "r", stdin); freopen("output2.txt", "w", stdout);
#define qw3 freopen("input3.txt", "r", stdin); freopen("output3.txt", "w", stdout);
#define qw4 freopen("input4.txt", "r", stdin); freopen("output4.txt", "w", stdout);
#define qw5 freopen("input5.txt", "r", stdin); freopen("output5.txt", "w", stdout);
#define qw6 freopen("input6.txt", "r", stdin); freopen("output6.txt", "w", stdout);
#define qw freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
 
int dfs(int x,int y)
{
    vis[x][y]=1;
    A[x][y]=hh;
    for(int i=0;i<4;i++)
    {
    	int a=x+xa[i];
    	int b=y+ya[i];
    	if(check(a,b)==1 && vis[a][b]==0) dfs(a,b);
    }
}
signed main()
{
	
		
		cin>>n>>m;

		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
                 cin>>A[i][j];
                 
			}
		}
		int xx,yy,gg;
		cin>>xx>>yy>>gg;
		val=A[xx][yy];hh=gg;
		dfs(xx,yy);
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				cout<<A[i][j]<<" ";
			}
		}

		


	
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?