Opaser

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



 

分类:

技术点:

相关文章:

  • 2021-12-25
  • 2021-08-28
  • 2022-01-05
  • 2021-11-17
  • 2021-12-19
  • 2021-12-10
  • 2021-11-02
  • 2021-08-10
猜你喜欢
  • 2021-12-05
  • 2021-10-31
  • 2021-12-05
  • 2021-06-06
  • 2021-12-29
  • 2021-04-20
  • 2021-05-19
相关资源
相似解决方案