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;
}

最新文章

  1. poll机制
  2. HttpSession--会话
  3. html中出现的script失效
  4. 使用TypeScript开发程序
  5. 利用迅雷提供的接口从磁力链得到bt种子文件
  6. 在Ubuntu 中安装eclipse, eclipse 文件已经下载好!
  7. mybatis源代码分析:mybatis延迟加载机制改进
  8. vc++ ODBC
  9. UpdataData
  10. 使用PreListener与InteractionListener的一个小发现
  11. 融会贯通——最常用的“合成复用原则”技能点Get
  12. IP协议详解(转)
  13. Laravel5多图上传和Laravel5单图上传的功能实现
  14. python基础篇_006_面向对象
  15. JavaScript大杂烩1 - 理解JavaScript的类型系统
  16. 5410 ACM 杭电 01+完全背包
  17. Python并发编程之线程池/进程池--concurrent.futures模块
  18. 使用 Actuator 监控
  19. 16_python_面向对象
  20. linux高精度struct timespec 和 struct timeval

热门文章

  1. expect小工具,在postgresql中执行sql的shell脚本
  2. jenkins 集成redmine
  3. Spark2 Dataset分析函数--排名函数row_number,rank,dense_rank,percent_rank
  4. poj 2125 Destroying The Graph 最小割+方案输出
  5. opengl学习笔记(一)
  6. 2018牛客网暑期ACM多校训练营(第二场) A - run - [DP]
  7. _cs, _ci, or _bin,
  8. 2018/04/16 PHP 设计模式之工厂模式
  9. Java泛型初探
  10. CentOS 6 网络设置