For problem statement at 1000-1999/1000-1099/1030-1039/1032/problemD.txt this is a correct solution, but verifier at 1000-1999/1000-1099/1030-1039/1032/verifierD.go ends with test 1 failed
input:
0 1 0
0 0 1 1
expected: 2.000000000000
got: 2.0000000000
exit status 1 can you fix the verifier? package main
import (
"bufio"
"fmt"
"math"
"os"
)
type Node struct {
x, y, d float64
}
func main() {
in := bufio.NewReader(os.Stdin)
var a, b, c float64
var x1, y1, x2, y2 float64
if _, err := fmt.Fscan(in, &a, &b, &c); err != nil {
return
}
fmt.Fscan(in, &x1, &y1, &x2, &y2)
ans := math.Abs(x1-x2) + math.Abs(y1-y2)
var A, Bc []Node
if a != 0 {
xh1 := (-b*y1 - c) / a
A = append(A, Node{xh1, y1, math.Abs(xh1 - x1)})
xh2 := (-b*y2 - c) / a
Bc = append(Bc, Node{xh2, y2, math.Abs(xh2 - x2)})
}
if b != 0 {
yv1 := (-a*x1 - c) / b
A = append(A, Node{x1, yv1, math.Abs(yv1 - y1)})
yv2 := (-a*x2 - c) / b
Bc = append(Bc, Node{x2, yv2, math.Abs(yv2 - y2)})
}
for _, p := range A {
for _, q := range Bc {
d := p.d + q.d + math.Hypot(p.x-q.x, p.y-q.y)
if d < ans {
ans = d
}
}
}
out := bufio.NewWriter(os.Stdout)
fmt.Fprintf(out, "%.10f\n", ans)
out.Flush()
}