Pagini recente » Cod sursa (job #500030) | Cod sursa (job #1818190) | Cod sursa (job #272485) | Cod sursa (job #2973887) | Cod sursa (job #637067)
Cod sursa(job #637067)
#include<cstdio>
const int N = 1002;
int a[N][N], n, m;
void citire() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j)
scanf("%d", &a[i][j]);
}
bool palind(int lin, int y1, int y2) {
while (a[lin][y1] == a[lin][y2] && y1 < y2) {
++y1;
--y2;
}
if (y1 >= y2)
return true;
return false;
}
int scmax(int y1, int y2) {
int s = 0, smax = 0;
for (int i = 1; i <= n; ++i) {
if (s > smax)
smax = s;
if (palind(i, y1, y2))
++s;
else
s = 0;
}
return smax;
}
void rez() {
int amax = 0;
for (int j1 = 1; j1 <= m; ++j1)
for (int j2 = j1; j2 <= m; j2 += 2) {
int s = scmax(j1, j2);
if ((j2 - j1 + 1) * s > amax)
amax = (j2 - j1 + 1) * s;
}
printf("%d\n", amax);
}
int main() {
freopen("dreptpal.in", "r", stdin);
freopen("dreptpal.out", "w", stdout);
citire();
rez();
return 0;
}