For problem statement at 0-999/800-899/840-849/846/problemF.txt this is a correct solution, but verifier at 0-999/800-899/840-849/846/verifierF.go ends with All tests passed! can you fix the verifier? package main
import (
"fmt"
"io"
"os"
)
func main() {
buf, _ := io.ReadAll(os.Stdin)
var pos int
nextInt := func() int {
for pos < len(buf) && (buf[pos] < '0' || buf[pos] > '9') {
pos++
}
if pos >= len(buf) {
return 0
}
res := 0
for pos < len(buf) && buf[pos] >= '0' && buf[pos] <= '9' {
res = res*10 + int(buf[pos]-'0')
pos++
}
return res
}
n := nextInt()
if n == 0 {
return
}
last := make([]int, 1000005)
seen := make([]bool, 1000005)
var sumExcluded int64 = 0
var distinctCount int64 = 0
for i := 1; i <= n; i++ {
val := nextInt()
if !seen[val] {
seen[val] = true
distinctCount++
}
L := int64(i - last[val] - 1)
sumExcluded += L * L
last[val] = i
}
for val, isSeen := range seen {
if isSeen {
L := int64(n - last[val])
sumExcluded += L * L
}
}
expected := float64(distinctCount) - float64(sumExcluded)/float64(int64(n)*int64(n))
fmt.Printf("%.6f\n", expected)
}