Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int H, W; char s[1009][1009]; bool vis[1009][1009];
int main() {
????????scanf("%d%d", &H, &W);
????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
????????vector<pair<int, int> > v;
????????for (int i = 0; i < H; i++) {
????????????????for (int j = 0; j < W; j++) {
????????????????????????if (s[i][j] == '.' || s[i][j] == '9') continue;
????????????????????????int cnt = 0;
????????????????????????for (int k = -1; k <= 1; k++) {
????????????????????????????????for (int l = -1; l <= 1; l++) {
????????????????????????????????????????int tx = j + l, ty = i + k;
????????????????????????????????????????if (0 <= tx && tx < W && 0 <= ty && ty < H && s[ty][tx] == '.') cnt++;
????????????????????????????????}
????????????????????????}
????????????????????????if (cnt >= s[i][j] - 48) v.push_back(make_pair(j, i));
????????????????}
????????}
????????int ret = 0;
????????for (; !v.empty(); ret++) {
????????????????for (pair<int, int> i : v) s[i.second][i.first] = '.';
????????????????vector<pair<int, int> > w;
????????????????for (pair<int, int> i : v) {
????????????????????????int sx = i.first, sy = i.second;
????????????????????????for (int j = -1; j <= 1; j++) {
????????????????????????????????for (int k = -1; k <= 1; k++) {
????????????????????????????????????????int tx = sx + k, ty = sy + j;
????????????????????????????????????????if (!(0 <= tx && tx < W && 0 <= ty && ty < H)) continue;
????????????????????????????????????????if (s[ty][tx] == '.' || s[ty][tx] == '9' || vis[ty][tx]) continue;
????????????????????????????????????????int cnt = 0;
????????????????????????????????????????for (int l = -1; l <= 1; l++) {
????????????????????????????????????????????????for (int m = -1; m <= 1; m++) {
????????????????????????????????????????????????????????int ux = tx + m, uy = ty + l;
????????????????????????????????????????????????????????if (0 <= ux && ux < W && 0 <= uy && uy < H && s[uy][ux] == '.') cnt++;
????????????????????????????????????????????????}
????????????????????????????????????????}
????????????????????????????????????????if (cnt >= s[ty][tx] - 48) w.push_back(make_pair(tx, ty)), vis[ty][tx] = true;
????????????????????????????????}
????????????????????????}
????????????????}
????????????????for (pair<int, int> i : w) vis[i.second][i.first] = false;
????????????????v = w;
????????}
????????printf("%d\n", ret);
????????return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:1: error: expected primary-expression before '?' token
    7 | ????????scanf("%d%d", &H, &W);
      | ^
a.cc:7:2: error: expected primary-expression before '?' token
    7 | ????????scanf("%d%d", &H, &W);
      |  ^
a.cc:7:3: error: expected primary-expression before '?' token
    7 | ????????scanf("%d%d", &H, &W);
      |   ^
a.cc:7:4: error: expected primary-expression before '?' token
    7 | ????????scanf("%d%d", &H, &W);
      |    ^
a.cc:7:5: error: expected primary-expression before '?' token
    7 | ????????scanf("%d%d", &H, &W);
      |     ^
a.cc:7:6: error: expected primary-expression before '?' token
    7 | ????????scanf("%d%d", &H, &W);
      |      ^
a.cc:7:7: error: expected primary-expression before '?' token
    7 | ????????scanf("%d%d", &H, &W);
      |       ^
a.cc:7:8: error: expected primary-expression before '?' token
    7 | ????????scanf("%d%d", &H, &W);
      |        ^
a.cc:7:30: error: expected ':' before ';' token
    7 | ????????scanf("%d%d", &H, &W);
      |                              ^
      |                              :
a.cc:7:30: error: expected primary-expression before ';' token
a.cc:7:30: error: expected ':' before ';' token
    7 | ????????scanf("%d%d", &H, &W);
      |                              ^
      |                              :
a.cc:7:30: error: expected primary-expression before ';' token
a.cc:7:30: error: expected ':' before ';' token
    7 | ????????scanf("%d%d", &H, &W);
      |                              ^
      |                              :
a.cc:7:30: error: expected primary-expression before ';' token
a.cc:7:30: error: expected ':' before ';' token
    7 | ????????scanf("%d%d", &H, &W);
      |                              ^
      |                              :
a.cc:7:30: error: expected primary-expression before ';' token
a.cc:7:30: error: expected ':' before ';' token
    7 | ????????scanf("%d%d", &H, &W);
      |                              ^
      |                              :
a.cc:7:30: error: expected primary-expression before ';' token
a.cc:7:30: error: expected ':' before ';' token
    7 | ????????scanf("%d%d", &H, &W);
      |                              ^
      |                              :
a.cc:7:30: error: expected primary-expression before ';' token
a.cc:7:30: error: expected ':' before ';' token
    7 | ????????scanf("%d%d", &H, &W);
      |                              ^
      |                              :
a.cc:7:30: error: expected primary-expression before ';' token
a.cc:7:30: error: expected ':' before ';' token
    7 | ????????scanf("%d%d", &H, &W);
      |                              ^
      |                              :
a.cc:7:30: error: expected primary-expression before ';' token
a.cc:8:1: error: expected primary-expression before '?' token
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      | ^
a.cc:8:2: error: expected primary-expression before '?' token
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |  ^
a.cc:8:3: error: expected primary-expression before '?' token
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |   ^
a.cc:8:4: error: expected primary-expression before '?' token
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |    ^
a.cc:8:5: error: expected primary-expression before '?' token
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |     ^
a.cc:8:6: error: expected primary-expression before '?' token
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |      ^
a.cc:8:7: error: expected primary-expression before '?' token
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |       ^
a.cc:8:8: error: expected primary-expression before '?' token
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |        ^
a.cc:8:9: error: expected primary-expression before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
a.cc:8:9: error: expected ':' before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
      |         :
a.cc:8:9: error: expected primary-expression before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
a.cc:8:9: error: expected ':' before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
      |         :
a.cc:8:9: error: expected primary-expression before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
a.cc:8:9: error: expected ':' before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
      |         :
a.cc:8:9: error: expected primary-expression before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
a.cc:8:9: error: expected ':' before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
      |         :
a.cc:8:9: error: expected primary-expression before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
a.cc:8:9: error: expected ':' before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
      |         :
a.cc:8:9: error: expected primary-expression before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
a.cc:8:9: error: expected ':' before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
      |         :
a.cc:8:9: error: expected primary-expression before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
a.cc:8:9: error: expected ':' before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
      |         :
a.cc:8:9: error: expected primary-expression before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
a.cc:8:9: error: expected ':' before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
      |         :
a.cc:8:9: error: expected primary-expression before 'for'
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |         ^~~
a.cc:8:25: error: 'i' was not declared in this scope
    8 | ????????for (int i = 0; i < H; i++) scanf("%s", s[i]);
      |                         ^
a.cc:9:1: error: expected primary-expression before '?' token
    9 | ????????vector<pair<int, int> > v;
      | ^
a.cc:9:2: error: expected primary-expression before '?' token
    9 | ????????vector<pair<int, int> > v;
      |  ^
a.cc:9:3: error: expected primary-expression before '?' token
    9 | ????????vector<pair<int, int> > v;
      |   ^
a.cc:9:4: error: expected primary-expression before '?' token
    9 | ????????vector<pair<int, int> > v;
      |    ^
a.cc:9:5: error: expected primary-expression before '?' token
    9 | ????????vector<pair<int, int> > v;
      |     ^
a.cc:9:6: error: expected primary-expression before '?' token
    9 | ????????vector<pair<int, int> > v;
      |      ^
a.cc:9:7: error: expected primary-expression before '?' token
    9 | ????????vector<pair<int, int> > v;
      |       ^
a.cc:9:8: error: expected primary-expression before '?' token
    9 | ????????vector<pair<int, int> > v;
      |        ^
a.cc:9:33: error: expected primary-expression before 'v'
    9 | ????????vector<pair<int, int> > v;
      |                                 ^
a.cc:9:32: error: expected ':' before 'v'
    9 | ????????vector<pair<int, int> > v;
      |                                ^~
      |                                :
a.cc:9:33: error: 'v' was not declared in this scope
    9 | ????????vector<pair<int, int> > v;
      |                                 ^
a.cc:9:34: error: expected ':' before ';' token
    9 | ????????vector<pair<int, int> > v;
      |                                  ^
      |                                  :
a.cc:9:34: error: expected primary-expression before ';' token
a.cc:9:34: error: expected ':' before ';' token
    9 | ????????vector<pair<int, int> > v;
      |                                  ^
      |                                  :
a.cc:9:34: error: expected primary-expression before ';' token
a.cc:9:34: error: expected ':' before ';' token
    9 | ????????vector<pair<int, int> > v;
      |                                  ^
      |                                  :
a.cc:9:34: error: expected primary-expression before ';' token
a.cc:9:34: error: expected ':' before ';' token
    9 | ????????vector<pair<int, int> > v;
      |                                  ^
      |                                  :
a.cc:9:34: error: expected primary-expression before ';' token
a.cc:9:34: error: expected ':' before ';' token
    9 | ????????vector<pair<int, int> > v;
      |                                  ^
      |                                  :
a.cc:9:34: error: expected primary-expression before ';' token
a.cc:9:34: error: expected ':' before ';' token
    9 | ????????vector<pair<int, int> > v;
      |                                  ^
      |                                  :
a.cc:9:34: error: expected primary-expression before ';' token
a.cc:9:34: error: expected ':' before ';' token
    9 | ????????vector<pair<int, int> > v;
      |                                  ^
      |                                  :
a.cc:9:34: error: expected primary-expression before ';' token
a.cc:10:1: error: expected primary-expression before '?' token
   10 | ????????for (int i = 0; i < H; i++) {
      | ^
a.cc:10:2: error: expected primary-expression before '?' token
   10 | ????????for (int i = 0; i < H; i++) {
      |  ^
a.cc:10:3: error: expected primary-expression before '?' token
   10 | ????????for (int i = 0; i < H; i++) {
      |   ^
a.cc:10:4: error: expected primary-expression before '?' token
   10 | ????????for (int i = 0; i < H; i++) {
      |    ^
a.cc:10:5: error: expected primary-expression before '?' token
   10 | ????????for (int i = 0; i < H; i++) {
      |     ^
a.cc:10:6: error: expected primary-expression before '?' token
   10 | ????????for (int i = 0; i < H; i++) {