您的位置:首页 > 其它

3/5/2014 cfb 小心

2014-03-08 11:22 369 查看
During each move the player can choose all lines of the matrix where dwarf is not on the cell with candy and shout "Let's go!"

这个 看成是 选其所有干行 我却看成是选其中 若干 行 水一下自己

#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
using namespace std;
char map[1005][1005];
int N[1005],L[1005];
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)==2){
bool flag=0;
for(int i=0;i<n;i++){
scanf("%s",map[i]);
for(int j=0;j<m;j++)
if(map[i][j]=='G'){ L[i]=j;break; }
}
for(int i=0;i<n;i++){
int j;
for(  j=L[i];j<m;j++)if( map[i][j]=='S'){ N[i]=j-L[i];break; }
if(j==m){ flag=1;break;}
}
if(flag){ printf("-1\n"); }
else {
int num=1;
sort(N,N+n);
for(int i=0;i<n-1;i++)
if(N[i]!=N[i+1])
num++;
printf("%d\n",num);
}

}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: