← Home
For problem statement at 0-999/700-799/760-769/767/problemA.txt this is a correct solution, but verifier at 0-999/700-799/760-769/767/verifierA.go ends with All tests passed can you fix the verifier? package main

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

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
	}

	n := nextInt()
	seen := make([]bool, n+2)
	cur := n

	var out strings.Builder
	out.Grow(n * 8)

	for i := 0; i < n; i++ {
		x := nextInt()
		seen[x] = true
		first := true
		for cur >= 1 && seen[cur] {
			if !first {
				out.WriteByte(' ')
			}
			out.WriteString(strconv.Itoa(cur))
			first = false
			cur--
		}
		out.WriteByte('\n')
	}

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