← Home
For problem statement at 1000-1999/1900-1999/1920-1929/1928/problemE.txt this is a correct solution, but verifier at 1000-1999/1900-1999/1920-1929/1928/verifierE.go ends with OK can you fix the verifier? ```go
package main

import (
	"bufio"
	"io"
	"os"
	"strconv"
)

type Test struct {
	n, x, y, s int
}

func main() {
	data, _ := io.ReadAll(os.Stdin)
	idx := 0
	nextInt := func() int {
		for idx < len(data) && (data[idx] < '0' || data[idx] > '9') && data[idx] != '-' {
			idx++
		}
		sign := 1
		if idx < len(data) && data[idx] == '-' {
			sign = -1
			idx++
		}
		val := 0
		for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
			val = val*10 + int(data[idx]-'0')
			idx++
		}
		return sign * val
	}

	t := nextInt()
	tests := make([]Test, t)
	maxS := 0
	for i := 0; i < t; i++ {
		n := nextInt()
		x := nextInt()
		y := nextInt()
		s := nextInt()
		tests[i] = Test{n, x, y, s}
		if s > maxS {
			maxS = s
		}
	}

	inf := 1 << 30
	minCost := make([]int, maxS+1)
	prev := make([]int, maxS+1)
	pick := make([]int, maxS+1)
	for i := 1; i <= maxS; i++ {
		minCost[i] = inf
		prev[i] = -1
	}

	for r := 1; ; r++ {
		v := r * (r + 1) / 2
		if v > maxS {
			break
		}
		c := r + 1
		for sum := v; sum <= maxS; sum++ {
			if minCost[sum-v] == inf {
				continue
			}
			nc := minCost[sum-v] + c
			if nc < minCost[sum] {
				minCost[sum] = nc
				prev[sum] = sum - v
				pick[sum] = r
			}
		}
	}

	out := make([]byte, 0, 1<<20)

	for _, tc := range tests {
		n, x, y, s := tc.n, tc.x, tc.y, tc.s
		r := x % y
		q := x / y

		total := int64(s) - int64(n)*int64(r)
		if total < 0 || total%int64(y) != 0 {
			out = append(out, "No\n"...)
			continue
		}

		T := int(total / int64(y))
		if T < 0 || T > maxS {
			out = append(out, "No\n"...)
			continue
		}

		foundL := -1
		foundRem := 0

		for l := 1; l <= n; l++ {
			base := int64(l)*int64(q) + int64(l)*int64(l-1)/2
			if base > int64(T) {
				break
			}
			rem := T - int(base)
			if minCost[rem] <= n-l {
				foundL = l
				foundRem = rem
				break
			}
		}

		if foundL == -1 {
			out = append(out, "No\n"...)
			continue
		}

		out = append(out, "Yes\n"...)

		first := true
		emit := func(v int64) {
			if !first {
				out = append(out, ' ')
			}
			first = false
			out = strconv.AppendInt(out, v, 10)
		}

		r64 := int64(r)
		y64 := int64(y)

		for i := 0; i < foundL; i++ {
			emit(r64 + y64*int64(q+i))
		}

		m := n - foundL
		if m > 0 {
			runs := make([]int, 0)
			used := 0
			cur := foundRem
			for cur > 0 {
				rr := pick[cur]
				runs = append(runs, rr)
				used += rr + 1
				cur = prev[cur]
			}

			for _, rr := range runs {
				for v := 0; v <= rr; v++ {
					emit(r64 + y64*int64(v))
				}
			}

			for i := 0; i < m-used; i++ {
				emit(r64)
			}
		}

		out = append(out, '\n')
	}

	w := bufio.NewWriterSize(os.Stdout, 1<<20)
	w.Write(out)
	w.Flush()
}
```