← Home
For problem statement at 1000-1999/1600-1699/1610-1619/1619/problemD.txt this is a correct solution, but verifier at 1000-1999/1600-1699/1610-1619/1619/verifierD.go ends with All tests passed can you fix the verifier? package main

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

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

	t := nextInt()
	out := bufio.NewWriterSize(os.Stdout, 1<<20)
	defer out.Flush()

	for ; t > 0; t-- {
		m := nextInt()
		n := nextInt()

		colMax := make([]int, n)
		maxSecond := 0

		for i := 0; i < m; i++ {
			first, second := 0, 0
			for j := 0; j < n; j++ {
				x := nextInt()
				if x > colMax[j] {
					colMax[j] = x
				}
				if x >= first {
					second = first
					first = x
				} else if x > second {
					second = x
				}
			}
			if second > maxSecond {
				maxSecond = second
			}
		}

		minCol := colMax[0]
		for j := 1; j < n; j++ {
			if colMax[j] < minCol {
				minCol = colMax[j]
			}
		}

		ans := minCol
		if maxSecond < ans {
			ans = maxSecond
		}

		out.WriteString(strconv.Itoa(ans))
		out.WriteByte('\n')
	}
}