func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Node {     pair<int, int> A;     int x, y;     Node() {}     Node(pair<int, int> A, int x, int y) {       this->A = A;       this->x = x;       this->y = y;     }   };   char s[1001][1001];   int sp[10], cur, ans[10];   Node heap[1000001];   void swap(Node& a, Node& b) {     Node t = a;     a = b;     b = t;   }   bool cmp(Node a, Node b) {     int val_a = a.A.first / sp[a.A.second];     int val_b = b.A.first / sp[b.A.second];     if (val_a != val_b)       return val_a < val_b;     else if (a.A.second != b.A.second)       return a.A.second < b.A.second;     else       return a.A.first < b.A.first;   }   void push(Node x) {     int now = cur++;     heap[now] = x;     while (now > 1) {       int par = now / 2;       if (cmp(heap[now], heap[par]))         swap(heap[now], heap[par]);       else         break;       now = par;     }     return;   }   Node pop() {     Node ret = heap[1];     heap[1] = heap[--cur];     int now = 1;     while (now * 2 < cur) {       int l = now * 2, r = now * 2 + 1, t;       if (r == cur) r = l;       if (cmp(heap[l], heap[r]))         t = l;       else         t = r;       if (cmp(heap[t], heap[now]))         swap(heap[t], heap[now]);       else         break;       now = t;     }     return ret;   }   int dx[4] = {1, 0, 0, -1};   int dy[4] = {0, 1, -1, 0};   int main() {     int n, m, p;     cur = 1;     scanf( %d %d %d , &n, &m, &p);     for (int i = 1; i <= p; i++) scanf( %d , &sp[i]);     for (int i = 0; i < n; i++) scanf( %s , s[i]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if (s[i][j] >=  0  && s[i][j] <=  9 ) {           push(Node(pair<int, int>(0, s[i][j] -  0 ), i, j));         }       }     while (cur > 1) {       Node now = pop();       pair<int, int> A = now.A;       int x = now.x, y = now.y;       int cnt = A.first, who = A.second;       for (int i = 0; i < 4; i++) {         int nx = x + dx[i], ny = y + dy[i];         if (nx < 0 || ny < 0 || nx >= n || ny >= m || s[nx][ny] !=  . ) continue;         s[nx][ny] =  0  + who;         push(Node(pair<int, int>(cnt + 1, who), nx, ny));       }     }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if (s[i][j] >=  0  && s[i][j] <=  9 ) {           ans[s[i][j] -  0 ]++;         }       }     for (int i = 1; i <= p; i++) printf( %d  , ans[i]);     return 0;   }   