← Home
For problem statement at 1000-1999/1000-1099/1040-1049/1044/problemC.txt this is a correct solution, but verifier at 1000-1999/1000-1099/1040-1049/1044/verifierC.go ends with test 1 failed
input:
8
91 40
82 57
55 83
-88 45
-92 38
-51 -85
-38 -92
93 -36
expected: 646 720 720 720 720 720
got: 646
720
720
720
720
720

exit status 1 can you fix the verifier? package main

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

func main() {
	data, _ := io.ReadAll(bufio.NewReaderSize(os.Stdin, 1<<20))
	idx := 0
	nextInt := func() int64 {
		for idx < len(data) && (data[idx] == ' ' || data[idx] == '\n' || data[idx] == '\r' || data[idx] == '\t') {
			idx++
		}
		sign := int64(1)
		if data[idx] == '-' {
			sign = -1
			idx++
		}
		var v int64
		for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
			v = v*10 + int64(data[idx]-'0')
			idx++
		}
		return v * sign
	}

	max64 := func(a, b int64) int64 {
		if a > b {
			return a
		}
		return b
	}

	const inf int64 = 1 << 60

	n := int(nextInt())

	xmin, xmax := inf, -inf
	ymin, ymax := inf, -inf
	minSum, maxSum := inf, -inf
	maxYX, maxXY := -inf, -inf

	for i := 0; i < n; i++ {
		x := nextInt()
		y := nextInt()

		if x < xmin {
			xmin = x
		}
		if x > xmax {
			xmax = x
		}
		if y < ymin {
			ymin = y
		}
		if y > ymax {
			ymax = y
		}

		s := x + y
		if s < minSum {
			minSum = s
		}
		if s > maxSum {
			maxSum = s
		}

		yx := y - x
		if yx > maxYX {
			maxYX = yx
		}

		xy := x - y
		if xy > maxXY {
			maxXY = xy
		}
	}

	fullWH := (xmax - xmin) + (ymax - ymin)
	fullPerim := fullWH * 2

	triWH := max64(
		max64(maxSum-xmin-ymin, maxYX+xmax-ymin),
		max64(xmax+ymax-minSum, maxXY-xmin+ymax),
	)
	triPerim := triWH * 2

	w := bufio.NewWriterSize(os.Stdout, 1<<20)
	defer w.Flush()

	w.WriteString(strconv.FormatInt(triPerim, 10))
	for k := 4; k <= n; k++ {
		w.WriteByte('\n')
		w.WriteString(strconv.FormatInt(fullPerim, 10))
	}
}