# SRM439 Div2 250 SquareOfDigits

```// BEGIN CUT HERE
// END CUT HERE
#include <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,n,m) for(int i=(n);i<(m);i++)

class SquareOfDigits {
public:
int getMax(vector <string> data) {
int min = std::min(data.at(0).size(), data.size());
int result = min;
int i = 0;
while(i + min <= (int) data.size()) {
int j = 0;
while(j + min <= (int) data.at(0).size()) {
if (data[i][j] == data[i + result - 1][j]
&&
data[i][j] == data[i][j + result - 1]
&&
data[i][j] == data[i + result - 1][j + result - 1]) {
std::cout << i + 1 << ", " << j + 1 << ", " << data[i][j] << std::endl;
return result * result;
} else {
j++;
}
}
std::cout << "i :" << i << std::endl;
std::cout << "j :" << j << std::endl;
std::cout << "result :" << result << std::endl;
i++;
result--;
}
if (result != 1) result--;
return result * result;

};

void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { string Arr0[] = {"12",
"34"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 1; verify_case(0, Arg1, getMax(Arg0)); }
void test_case_1() { string Arr0[] = {"1255",
"3455"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 4; verify_case(1, Arg1, getMax(Arg0)); }
void test_case_2() { string Arr0[] = {"42101",
"22100",
"22101"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 9; verify_case(2, Arg1, getMax(Arg0)); }
void test_case_3() { string Arr0[] = {"1234567890"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 1; verify_case(3, Arg1, getMax(Arg0)); }
void test_case_4() { string Arr0[] = {"9785409507",
"2055103694",
"0861396761",
"3073207669",
"1233049493",
"2300248968",
"9769239548",
"7984130001",
"1670020095",
"8894239889",
"4053971072"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 49; verify_case(4, Arg1, getMax(Arg0)); }

// END CUT HERE

};

// BEGIN CUT HERE
int main() {
SquareOfDigits ___test;
___test.run_test(-1);
}

// END CUT HERE
```