やるだけ
class FindingSquareInTable { public: int findMaximalSquare(vector <string> table) { const int H = table.size(); const int W = table[0].size(); set<lli> s; for (lli i = 0; i * i <= 999999999LL; ++i) { s.insert(i * i); } lli mx = -1; for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { for (int a = -10; a <= +10; ++a) { for (int b = -10; b <= +10; ++b) { if (a == 0 && b == 0) continue; string t; int v = i; int u = j; while (0 <= v && v < H && 0 <= u && u < W) { t += table[v][u]; v += a; u += b; lli n = atoll(t.c_str()); if (s.count(n)) mx = max(mx, n); } } } } } return mx; } };