General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
5944691 Practice:
TsunamiNoLetGo
400B - 17 GNU C++ Accepted 124 ms 16 KB 2014-03-05 22:10:08 2014-03-05 22:10:08
 
 
→ Source
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<string>
#include<utility>
using namespace std;
int n,m;
int tab[1010][2];
vector<int> tod;
int main(){
    cin >> n  >> m;
    char c;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            cin>>c;
            if(c=='G') tab[i][0]=j;
            if(c=='S') tab[i][1]=j;
        }

    for(int i=0;i<n;i++)
        tod.push_back(tab[i][1]-tab[i][0]);

    sort(tod.begin(),tod.end());
    int i=0;
    if(tod[0]<=0){
        cout << -1 << endl;
        return 0;
    }
    int cnt=0;
    while(i<n){
        int tmp = tod[i];
        while(tod[i+1]==tmp) i++;
        i++;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details