Created
February 13, 2017 17:21
-
-
Save KhaledElshamy/c36c9684a4b36467a245d267a900c9b3 to your computer and use it in GitHub Desktop.
B. Inna and New Matrix of Candies-Codeforces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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