← Home
For problem statement at 2000-2999/2000-2099/2060-2069/2061/problemC.txt this is a correct solution, but verifier at 2000-2999/2000-2099/2060-2069/2061/verifierC.go ends with All 214 tests passed can you fix the verifier? package main

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

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

	buf := make([]byte, 0, 1024*1024)
	scanner.Buffer(buf, 10*1024*1024)

	scanInt := func() int {
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		return n
	}

	if !scanner.Scan() {
		return
	}
	t, _ := strconv.Atoi(scanner.Text())

	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	for tc := 0; tc < t; tc++ {
		n := scanInt()
		a := make([]int, n+1)
		for i := 1; i <= n; i++ {
			a[i] = scanInt()
		}

		dp0 := 0
		dp1 := 1
		if a[1] == 0 {
			dp0 = 1
		}

		for i := 2; i <= n; i++ {
			nextDp0 := 0
			if a[i] == a[i-1] {
				nextDp0 += dp0
				if nextDp0 >= 998244353 {
					nextDp0 -= 998244353
				}
			}
			if a[i] == a[i-2]+1 {
				nextDp0 += dp1
				if nextDp0 >= 998244353 {
					nextDp0 -= 998244353
				}
			}

			dp1 = dp0
			dp0 = nextDp0
		}

		ans := dp0 + dp1
		if ans >= 998244353 {
			ans -= 998244353
		}
		fmt.Fprintln(writer, ans)
	}
}