func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 505, M = 10;   int ST[N][N][M][M], a[N][N], lg[N];   void build(int n, int m) {     for (int i = 2; i <= max(n, m); i++) {       lg[i] = lg[i / 2] + 1;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         ST[i][j][0][0] = a[i][j];       }     }     for (int i = 1; i <= n; i++) {       for (int k = 1; (1 << k) <= m; k++) {         for (int j = 1; j + (1 << k) - 1 <= m; j++) {           ST[i][j][0][k] =               max(ST[i][j][0][k - 1], ST[i][j + (1 << (k - 1))][0][k - 1]);         }       }     }     for (int k1 = 1; (1 << k1) <= n; k1++) {       for (int i = 1; i + (1 << k1) - 1 <= n; i++) {         for (int k2 = 0; (1 << k2) <= m; k2++) {           for (int j = 1; j + (1 << k2) - 1 <= m; j++) {             ST[i][j][k1][k2] =                 max(ST[i][j][k1 - 1][k2], ST[i + (1 << (k1 - 1))][j][k1 - 1][k2]);           }         }       }     }   }   int query(int x1, int y1, int x2, int y2) {     if (x2 < x1 || y2 < y1) return 0;     const int k1 = lg[x2 - x1 + 1], k2 = lg[y2 - y1 + 1];     x2 = x2 - (1 << k1) + 1;     y2 = y2 - (1 << k2) + 1;     return max({ST[x1][y1][k1][k2], ST[x1][y2][k1][k2], ST[x2][y1][k1][k2],                 ST[x2][y2][k1][k2]});   }   int dp[N][N][4];   char s[N][N];   int main() {     ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     int n, m, q;     cin >> n >> m >> q;     for (int i = 1; i <= n; i++) {       cin >> (s[i] + 1);     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (s[i][j] ==  R ) {           dp[i][j][0] =               min({dp[i][j - 1][0], dp[i - 1][j][0], dp[i - 1][j - 1][0]}) + 1;         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = m; j >= 1; j--) {         if (s[i][j] ==  G ) {           dp[i][j][1] =               min({dp[i][j + 1][1], dp[i - 1][j][1], dp[i - 1][j + 1][1]}) + 1;         }       }     }     for (int i = n; i >= 1; i--) {       for (int j = 1; j <= m; j++) {         if (s[i][j] ==  Y ) {           dp[i][j][2] =               min({dp[i][j - 1][2], dp[i + 1][j][2], dp[i + 1][j - 1][2]}) + 1;         }       }     }     for (int i = n; i >= 1; i--) {       for (int j = m; j >= 1; j--) {         if (s[i][j] ==  B ) {           dp[i][j][3] =               min({dp[i][j + 1][3], dp[i + 1][j][3], dp[i + 1][j + 1][3]}) + 1;         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         a[i][j] = min(             {dp[i][j][0], dp[i][j + 1][1], dp[i + 1][j][2], dp[i + 1][j + 1][3]});       }     }     build(n, m);     while (q--) {       int r1, r2, c1, c2;       cin >> r1 >> c1 >> r2 >> c2;       int left = 0, right = min(c2 - c1 + 1, r2 - r1 + 1) / 2;       int ans = 0;       while (left <= right) {         int mid = (left + right) >> 1;         if (query(r1 + mid - 1, c1 + mid - 1, r2 - mid, c2 - mid) >= mid) {           left = mid + 1;           ans = mid;         } else {           right = mid - 1;         }       }       cout << (ans * ans * 4) <<   n ;     }   }   