For problem statement at 0-999/100-199/170-179/170/problemA.txt this is a correct solution, but verifier at 0-999/100-199/170-179/170/verifierA.go ends with case 1 mismatch
expected:
-1 -1 -1 -1
-1 -1 -1 -1
-1 -1 -1 -1
-1 -1 -1 -1
-1 -1 -1 -1
got:
0.0 0.0 57.3 15.7
-1 -1 -1 -1
0.0 15.7 44.5 35.3
-1 -1 -1 -1
0.0 35.3 4.6 49.7
exit status 1 can you fix the verifier? package main
import (
"fmt"
"math/rand"
"time"
)
type Rect struct {
w, h int
id int
}
type Placed struct {
id int
x1, y1 float64
x2, y2 float64
rot bool
}
func main() {
rand.Seed(time.Now().UnixNano())
var w, h int
if _, err := fmt.Scan(&w, &h); err != nil {
return
}
var n int
if _, err := fmt.Scan(&n); err != nil {
return
}
rects := make([]Rect, n)
for i := 0; i < n; i++ {
fmt.Scan(&rects[i].w, &rects[i].h)
rects[i].id = i
}
placed := make([]Placed, n)
for i := 0; i < n; i++ {
placed[i] = Placed{id: i, x1: -1, y1: -1, x2: -1, y2: -1}
}
if n > 0 {
var x float64 = 0
var y float64 = 0
var currentH float64 = 0
for i := 0; i < n; i++ {
r := rects[i]
rot := rand.Intn(2) == 1
rw := float64(r.w)
rh := float64(r.h)
if rot {
rw, rh = rh, rw
}
scale := 0.1 + rand.Float64()*1.9
rw *= scale
rh *= scale
rw = float64(int(rw*10)) / 10.0
rh = float64(int(rh*10)) / 10.0
if rw <= 0 || rh <= 0 {
continue
}
if x+rw > float64(w) {
x = 0
y += currentH
currentH = 0
}
if y+rh > float64(h) {
continue
}
placed[i] = Placed{
id: r.id,
x1: x,
y1: y,
x2: x + rw,
y2: y + rh,
rot: rot,
}
x += rw
if rh > currentH {
currentH = rh
}
}
}
for i := 0; i < n; i++ {
p := placed[i]
if p.x1 == -1 {
fmt.Println("-1 -1 -1 -1")
} else {
fmt.Printf("%.1f %.1f %.1f %.1f\n", p.x1, p.y1, p.x2, p.y2)
}
}
}