← Home
For problem statement at 0-999/500-599/570-579/577/problemB.txt this is a correct solution, but verifier at 0-999/500-599/570-579/577/verifierB.go ends with All 100 tests passed can you fix the verifier? package main

import (
	"fmt"
	"io"
	"os"
)

type FastScanner struct {
	data []byte
	idx  int
	n    int
}

func NewFastScanner() *FastScanner {
	data, _ := io.ReadAll(os.Stdin)
	return &FastScanner{data: data, n: len(data)}
}

func (fs *FastScanner) NextInt() int {
	for fs.idx < fs.n {
		c := fs.data[fs.idx]
		if c != ' ' && c != '\n' && c != '\r' && c != '\t' {
			break
		}
		fs.idx++
	}
	sign := 1
	if fs.idx < fs.n && fs.data[fs.idx] == '-' {
		sign = -1
		fs.idx++
	}
	val := 0
	for fs.idx < fs.n {
		c := fs.data[fs.idx]
		if c < '0' || c > '9' {
			break
		}
		val = val*10 + int(c-'0')
		fs.idx++
	}
	return sign * val
}

func main() {
	fs := NewFastScanner()
	n := fs.NextInt()
	m := fs.NextInt()

	if n >= m {
		fmt.Print("YES")
		return
	}

	dp := make([]bool, m)

	for i := 0; i < n; i++ {
		x := fs.NextInt() % m
		if x == 0 {
			fmt.Print("YES")
			return
		}

		next := make([]bool, m)
		copy(next, dp)
		next[x] = true

		for r := 0; r < m; r++ {
			if dp[r] {
				next[(r+x)%m] = true
			}
		}

		dp = next
		if dp[0] {
			fmt.Print("YES")
			return
		}
	}

	fmt.Print("NO")
}