Created
March 20, 2014 09:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
string Matrix[1000]; | |
bool is1(int i, int i_end, int j); | |
int main() | |
{ | |
ios::sync_with_stdio(false); | |
int Case; | |
cin >> Case; | |
while (Case--) | |
{ | |
cin >> Matrix[0]; | |
int N = Matrix[0].size(); | |
for (int i = 1; i < N; ++i) | |
cin >> Matrix[i]; | |
int MSS = 0, Max = 0; | |
for (int Len = 1; Len <= N; ++Len) { | |
for (int i = 0; i + Len - 1 < N; ++i) { | |
MSS = 0; | |
for (int j = 0; j < N; ++j) { | |
if (is1(i, i+Len-1, j)) | |
MSS += Len; | |
else | |
MSS = 0; | |
if (MSS > Max) Max = MSS; | |
} | |
} | |
} | |
cout << Max << endl; | |
if (Case) cout << endl; | |
} | |
} | |
bool is1(int i, int i_end, int j) | |
{ | |
for (i; i <= i_end; ++i) | |
if (Matrix[i][j] != '1') | |
return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment