Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KhaledElshamy/c36c9684a4b36467a245d267a900c9b3 to your computer and use it in GitHub Desktop.
Save KhaledElshamy/c36c9684a4b36467a245d267a900c9b3 to your computer and use it in GitHub Desktop.
B. Inna and New Matrix of Candies-Codeforces
// working.cpp by Bill Weinman <http://bw.org/>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
string s;
vector<int>s1;
vector<int>::iterator it;
for(int i=1;i<=n;i++)
{
cin>>s;
s1.push_back(s.find('S')-s.find('G'));
}
sort(s1.begin(),s1.end());
it=unique(s1.begin(),s1.end());
s1.resize(distance(s1.begin(),it));
if(*s1.begin()<0)
cout<<"-1"<<endl;
else
cout<<s1.size()<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment