← Home
For problem statement at 1000-1999/1500-1599/1570-1579/1575/problemD.txt this is a correct solution, but verifier at 1000-1999/1500-1599/1570-1579/1575/verifierD.go ends with All tests passed can you fix the verifier? package main

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

func match(c byte, d byte, x int) bool {
	if c == '_' {
		return true
	}
	if c == 'X' {
		return byte('0'+x) == d
	}
	return c == d
}

func solve(s string, x int) int64 {
	n := len(s)
	if n == 1 {
		if match(s[0], '0', x) {
			return 1
		}
		return 0
	}

	endings := [4]string{"00", "25", "50", "75"}
	var ans int64

	for _, e := range endings {
		if !match(s[n-2], e[0], x) || !match(s[n-1], e[1], x) {
			continue
		}

		var ways int64 = 1

		if n == 2 {
			if e[0] == '0' {
				continue
			}
		} else {
			switch s[0] {
			case '_':
				ways = 9
			case 'X':
				if x == 0 {
					continue
				}
			case '0':
				continue
			}
			for i := 1; i <= n-3; i++ {
				if s[i] == '_' {
					ways *= 10
				}
			}
		}

		ans += ways
	}

	return ans
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(in, &s)

	hasX := false
	for i := 0; i < len(s); i++ {
		if s[i] == 'X' {
			hasX = true
			break
		}
	}

	var ans int64
	if hasX {
		for x := 0; x <= 9; x++ {
			ans += solve(s, x)
		}
	} else {
		ans = solve(s, 0)
	}

	fmt.Print(ans)
}