#include<iostream>
using namespace std;
#define k 6
int checkBoundry(int arr[k][k])
{
int i=0;
while(i<k)
{
if(arr[0][i] == 0 || arr[k-1][i] == 0 || arr[i][0] == 0 || arr[i][k-1]==0)
return 0;
i++;
}
return 1;
}
void findpool(int arr[k][k])
{
if(checkBoundry(arr))
{
int flag =0;
for(int i=0; i<k; i++)
for(int j=0; j<k; j++)
{
if((arr[i][j] == 0) &&( arr[i][j+1] == 0 || arr[i][j-1]==0 || arr[i+1][j]==0 || arr[i-1][j] == 0))
flag =1;
else if((arr[i][j]==0) && (arr[i-1][j-1] == 0 || arr[i-1][j+1]==0 || arr[i+1][j-1] == 0 || arr[i+1][j+1]==0))
{
flag = 0;
cout<<"matrix is NOT pool"<<endl;
return;
}
else
continue;
}
if(flag)
cout<<"matrix is pool"<<endl;
else
cout<<"matrix does is NOT pool"<<endl;
}
else
cout<<"matrix is NOT pool"<<endl;
}
int main()
{
int arr[k][k] = {{1,1,1,1,1,1},
{1,1,1,0,0,1},
{1,1,0,0,0,1},
{1,0,0,0,1,1},
{1,1,1,0,1,1},
{1,1,1,1,1,1}};
findpool(arr);
return 0;
}