#include <iostream>
using namespace std;
int dx[8] = {-1,0,1,-1,1,-1,0,1};
int dy[8] = {-1,-1,-1,0,0,1,1,1};
int main() {
int arr[9][9];
int r,c;
for (int i = 0;i < 9;i++) {
for (int j = 0;j < 9;j++) {
cin >> arr[i][j];
}
}
cin >> r >> c;
if (arr[r][c] == 1) {
cout << -1;
return 0;
}
int cnt = 0;
for (int i = 0;i < 8;i++) {
if (arr[r+dy[i]][c+dx]) {
cnt++;
}
}
cout << cnt;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: