← Home
For problem statement at 0-999/400-499/400-409/400/problemB.txt this is a correct solution, but verifier at 0-999/400-499/400-409/400/verifierB.go ends with All tests passed can you fix the verifier? package main

import (
	"fmt"
)

func main() {
	var n, m int
	if _, err := fmt.Scan(&n, &m); err != nil {
		return
	}

	distances := make(map[int]bool)
	possible := true

	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		gPos, sPos := -1, -1
		for j := 0; j < len(s); j++ {
			if s[j] == 'G' {
				gPos = j
			} else if s[j] == 'S' {
				sPos = j
			}
		}
		if gPos > sPos {
			possible = false
		} else if sPos > gPos {
			distances[sPos-gPos] = true
		}
	}

	if !possible {
		fmt.Println("-1")
	} else {
		fmt.Println(len(distances))
	}
}