http://codeforces.com/problemset/problem/688/A
题意:
我翻译的就是打群架,当前行都为 1 ,对手到齐了就打不过,否则可以打过,
输出的是连续打过的最大天数。
思路:
建立一个Map数组,当前行存在 0 就赢了今天......
最后遍历就可以了。
Code:
#include<stdio.h>
#include<cstring>
const int MYDD=1103;
const int MAXN=128;
int ANS[MAXN];
char Map[MAXN][MAXN];
int main() {
int n,d;
while(scanf("%d%d",&n,&d)!=EOF) {
// n 是列数
for(int j=0; j<d; j++) {
ANS[j]=0;
scanf("%s",Map[d]);
for(int k=0; k<n; k++) {
if(Map[d][k]=='0') {
ANS[j]=1;
break;
}
}
}
int ans=0,now=0;
ANS[d]=-1;
for(int j=0; j<d; j++) {
if(ANS[j])
now++;
else {
if(now>ans) ans=now;
now=0;
}
}
if(now>ans) ans=now;
printf("%d\n",ans);
}
return 0;
}