For problem statement at 0-999/900-999/990-999/995/problemC.txt this is a correct solution, but verifier at 0-999/900-999/990-999/995/verifierC.go ends with All tests passed can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
type Node struct {
x, y int64
left, right int
signLeft, signRight int
}
func lenSq(x, y int64) int64 {
return x*x + y*y
}
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
if !scanner.Scan() {
return
}
n, _ := strconv.Atoi(scanner.Text())
nodes := make([]Node, 1, 2*n+2)
active := make([]int, 0, n)
for i := 1; i <= n; i++ {
scanner.Scan()
x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
scanner.Scan()
y, _ := strconv.ParseInt(scanner.Text(), 10, 64)
nodes = append(nodes, Node{x: x, y: y})
active = append(active, i)
}
for len(active) >= 3 {
u := active[len(active)-1]
v := active[len(active)-2]
w := active[len(active)-3]
active = active[:len(active)-3]
pairs := [][2]int{{u, v}, {u, w}, {v, w}}
un := []int{w, v, u}
for idx, p := range pairs {
a, b := p[0], p[1]
if lenSq(nodes[a].x+nodes[b].x, nodes[a].y+nodes[b].y) <= 1000000000000 {
nodes = append(nodes, Node{x: nodes[a].x + nodes[b].x, y: nodes[a].y + nodes[b].y, left: a, right: b, signLeft: 1, signRight: 1})
active = append(active, len(nodes)-1)
active = append(active, un[idx])
break
}
if lenSq(nodes[a].x-nodes[b].x, nodes[a].y-nodes[b].y) <= 1000000000000 {
nodes = append(nodes, Node{x: nodes[a].x - nodes[b].x, y: nodes[a].y - nodes[b].y, left: a, right: b, signLeft: 1, signRight: -1})
active = append(active, len(nodes)-1)
active = append(active, un[idx])
break
}
}
}
if len(active) == 2 {
u, v := active[0], active[1]
if lenSq(nodes[u].x+nodes[v].x, nodes[u].y+nodes[v].y) <= 2250000000000 {
nodes = append(nodes, Node{x: nodes[u].x + nodes[v].x, y: nodes[u].y + nodes[v].y, left: u, right: v, signLeft: 1, signRight: 1})
} else {
nodes = append(nodes, Node{x: nodes[u].x - nodes[v].x, y: nodes[u].y - nodes[v].y, left: u, right: v, signLeft: 1, signRight: -1})
}
active = []int{len(nodes) - 1}
}
ans := make([]int, n+1)
var dfs func(int, int)
dfs = func(u int, sign int) {
if u <= n {
ans[u] = sign
return
}
dfs(nodes[u].left, sign*nodes[u].signLeft)
dfs(nodes[u].right, sign*nodes[u].signRight)
}
if len(active) > 0 {
dfs(active[0], 1)
}
var sb strings.Builder
for i := 1; i <= n; i++ {
sb.WriteString(strconv.Itoa(ans[i]))
if i < n {
sb.WriteByte(' ')
}
}
fmt.Println(sb.String())
}