← Home
For problem statement at 1000-1999/1400-1499/1440-1449/1446/problemC.txt this is a correct solution, but verifier at 1000-1999/1400-1499/1440-1449/1446/verifierC.go ends with All 104 tests passed can you fix the verifier? ```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	left     []int32
	right    []int32
	nodesCnt int32
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	// Max nodes = n * 30 roughly. 
	// 200,000 * 30 = 6,000,000. 
	// We allocate enough space.
	const maxNodes = 6500000
	left = make([]int32, maxNodes)
	right = make([]int32, maxNodes)

	// Initialize root (index 0)
	left[0] = -1
	right[0] = -1
	nodesCnt = 1

	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(in, &a)
		
		curr := int32(0)
		// We process up to 30 bits (0 to 10^9 < 2^30)
		for b := 29; b >= 0; b-- {
			bit := (a >> b) & 1
			if bit == 0 {
				if left[curr] == -1 {
					left[curr] = nodesCnt
					// Initialize the new node
					left[nodesCnt] = -1
					right[nodesCnt] = -1
					nodesCnt++
				}
				curr = left[curr]
			} else {
				if right[curr] == -1 {
					right[curr] = nodesCnt
					// Initialize the new node
					left[nodesCnt] = -1
					right[nodesCnt] = -1
					nodesCnt++
				}
				curr = right[curr]
			}
		}
	}

	maxGood := solve(0)
	fmt.Fprintln(out, n - maxGood)
}

func solve(u int32) int {
	// If we reached a leaf (or node with no children in trie), it represents 1 number.
	if left[u] == -1 && right[u] == -1 {
		return 1
	}

	l := 0
	if left[u] != -1 {
		l = solve(left[u])
	}

	r := 0
	if right[u] != -1 {
		r = solve(right[u])
	}

	if l == 0 {
		return r
	}
	if r == 0 {
		return l
	}

	// If both children exist, we can keep the larger subtree fully, 
	// plus exactly 1 element from the other subtree.
	// This satisfies the condition that at most one branch has > 1 element.
	if l > r {
		return l + 1
	}
	return r + 1
}
```