← Home
For problem statement at 0-999/400-499/490-499/490/problemE.txt this is a correct solution, but verifier at 0-999/400-499/490-499/490/verifierE.go ends with wrong answer on test 103: should be NO

exit status 1 can you fix the verifier? package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	out := bufio.NewWriter(os.Stdout)

	if !scanner.Scan() {
		return
	}
	n := 0
	for _, c := range scanner.Text() {
		n = n*10 + int(c-'0')
	}

	prev := ""
	ans := make([]string, 0, n)

	for i := 0; i < n; i++ {
		scanner.Scan()
		s := scanner.Text()

		if len(s) < len(prev) {
			fmt.Fprintln(out, "NO")
			out.Flush()
			return
		}

		if len(s) > len(prev) {
			r := []byte(s)
			if r[0] == '?' {
				r[0] = '1'
			}
			for j := 1; j < len(r); j++ {
				if r[j] == '?' {
					r[j] = '0'
				}
			}
			prev = string(r)
			ans = append(ans, prev)
			continue
		}

		found := false
		for k := len(s) - 1; k >= 0; k-- {
			canMatch := true
			for j := 0; j < k; j++ {
				if s[j] != '?' && s[j] != prev[j] {
					canMatch = false
					break
				}
			}
			if !canMatch {
				continue
			}

			r := []byte(s)
			for j := 0; j < k; j++ {
				r[j] = prev[j]
			}

			if r[k] == '?' {
				if prev[k] == '9' {
					continue
				}
				r[k] = prev[k] + 1
			} else {
				if r[k] <= prev[k] {
					continue
				}
			}

			for j := k + 1; j < len(s); j++ {
				if r[j] == '?' {
					r[j] = '0'
				}
			}

			prev = string(r)
			ans = append(ans, prev)
			found = true
			break
		}

		if !found {
			fmt.Fprintln(out, "NO")
			out.Flush()
			return
		}
	}

	fmt.Fprintln(out, "YES")
	for _, s := range ans {
		fmt.Fprintln(out, s)
	}
	out.Flush()
}