← Home
For problem statement at 0-999/100-199/100-109/105/problemE.txt this is a correct solution, but verifier at 0-999/100-199/100-109/105/verifierE.go ends with All tests passed can you fix the verifier? ```go
package main

import "fmt"

type State struct {
	pos        [3]int
	heldBy     [3]int
	hasMoved   [3]bool
	hasGrabbed [3]bool
	hasThrown  [3]bool
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var charPos [3]int
	var moveRange [3]int
	var throwRange [3]int

	fmt.Scan(&charPos[0], &moveRange[0], &throwRange[0])
	fmt.Scan(&charPos[1], &moveRange[1], &throwRange[1])
	fmt.Scan(&charPos[2], &moveRange[2], &throwRange[2])

	initial := State{
		pos:        [3]int{charPos[0], charPos[1], charPos[2]},
		heldBy:     [3]int{-1, -1, -1},
		hasMoved:   [3]bool{false, false, false},
		hasGrabbed: [3]bool{false, false, false},
		hasThrown:  [3]bool{false, false, false},
	}

	seen := make(map[State]struct{})
	queue := []State{initial}
	seen[initial] = struct{}{}

	maxReach := 0
	for i := 0; i < 3; i++ {
		maxReach = max(maxReach, charPos[i])
	}

	for len(queue) > 0 {
		curr := queue[0]
		queue = queue[1:]

		for i := 0; i < 3; i++ {
			maxReach = max(maxReach, curr.pos[i])
		}

		for actChar := 0; actChar < 3; actChar++ {
			if curr.heldBy[actChar] != -1 {
				continue
			}

			// Try move
			holdingSomeone := false
			for d := 0; d < 3; d++ {
				if curr.heldBy[d] == actChar {
					holdingSomeone = true
					break
				}
			}
			if !curr.hasMoved[actChar] && !holdingSomeone {
				p := curr.pos[actChar]
				for dist := 1; dist <= moveRange[actChar]; dist++ {
					for _, dir := range []int{-1, 1} {
						newp := p + dir*dist
						if newp < 1 {
							continue
						}
						free := true
						for k := 0; k < 3; k++ {
							if k != actChar && curr.heldBy[k] == -1 && curr.pos[k] == newp {
								free = false
								break
							}
						}
						if free {
							next := curr
							next.pos[actChar] = newp
							next.hasMoved[actChar] = true
							if _, ok := seen[next]; !ok {
								seen[next] = struct{}{}
								queue = append(queue, next)
							}
						}
					}
				}
			}

			// Try grab
			if !curr.hasGrabbed[actChar] {
				p := curr.pos[actChar]
				for t := 0; t < 3; t++ {
					if t == actChar || curr.heldBy[t] != -1 {
						continue
					}
					if abs(curr.pos[t]-p) != 1 {
						continue
					}
					next := curr
					next.heldBy[t] = actChar
					next.pos[t] = p
					u := -1
					for kk := 0; kk < 3; kk++ {
						if next.heldBy[kk] == t {
							u = kk
							break
						}
					}
					if u != -1 {
						next.pos[u] = p
						w := -1
						for kk := 0; kk < 3; kk++ {
							if next.heldBy[kk] == u {
								w = kk
								break
							}
						}
						if w != -1 {
							next.pos[w] = p
						}
					}
					next.hasGrabbed[actChar] = true
					if _, ok := seen[next]; !ok {
						seen[next] = struct{}{}
						queue = append(queue, next)
					}
				}
			}

			// Try throw
			if !curr.hasThrown[actChar] {
				thrown := -1
				for d := 0; d < 3; d++ {
					if curr.heldBy[d] == actChar {
						thrown = d
						break
					}
				}
				if thrown != -1 {
					p := curr.pos[actChar]
					for dist := 0; dist <= throwRange[actChar]; dist++ {
						for _, sign := range []int{-1, 1} {
							if dist == 0 && sign == -1 {
								continue
							}
							newp := p + sign*dist
							if newp < 1 {
								continue
							}
							free := true
							for k := 0; k < 3; k++ {
								if curr.heldBy[k] == -1 && curr.pos[k] == newp {
									free = false
									break
								}
							}
							if free {
								next := curr
								next.heldBy[thrown] = -1
								next.pos[thrown] = newp
								u := -1
								for kk := 0; kk < 3; kk++ {
									if next.heldBy[kk] == thrown {
										u = kk
										break
									}
								}
								if u != -1 {
									next.pos[u] = newp
									w := -1
									for kk := 0; kk < 3; kk++ {
										if next.heldBy[kk] == u {
											w = kk
											break
										}
									}
									if w != -1 {
										next.pos[w] = newp
									}
								}
								next.hasThrown[actChar] = true
								if _, ok := seen[next]; !ok {
									seen[next] = struct{}{}
									queue = append(queue, next)
								}
							}
						}
					}
				}
			}
		}
	}

	fmt.Println(maxReach)
}
```