package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) var rdr = bufio.NewReaderSize(os.Stdin, 1000000) func main() { sc.Split(bufio.ScanWords) n := nextInt() table := make([][]rune, n) for i := range table { s := nextLine() table[i] = []rune(s) } wins, games := make([]int, n), make([][2]int, 0, 15) for i, v := range table { for _, r := range v { if r == 'o' { wins[i]++ } } } for i, v := range table[:len(table)-1] { for j, r := range v[i+1:] { if r == '-' { games = append(games, [2]int{i, j + i + 1}) } } } fmt.Println(solve(games, wins)) } func solve(games [][2]int, wins []int) int { var f func(int, []int) int f = func(i int, wins []int) int { if i == len(games) { return check(wins) } wins[games[i][0]]++ rank1 := f(i+1, wins) wins[games[i][0]]-- wins[games[i][1]]++ rank2 := f(i+1, wins) wins[games[i][1]]-- if rank1 < rank2 { return rank1 } return rank2 } return f(0, wins) } func check(wins []int) int { w, m, rank := wins[0], make(map[int]bool), 1 for _, r := range wins { if m[r] { continue } m[r] = true if r > w { rank++ } } return rank } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }