← Home
For problem statement at 0-999/600-699/680-689/682/problemD.txt this is a correct solution, but verifier at 0-999/600-699/680-689/682/verifierD.go ends with case 4 failed: expected 5 got 2
input:
6 18 2
accccb
acbabaccabbbacbcba
exit status 1 can you fix the verifier? ```go
package main

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

	dp := make([][]int, k+1)
	for i := 0; i <= k; i++ {
		dp[i] = make([]int, m+1)
	}

	for i := 1; i <= n; i++ {
		newdp := make([][]int, k+1)
		for x := 0; x <= k; x++ {
			newdp[x] = make([]int, m+1)
			copy(newdp[x], dp[x])
		}

		prevLen := make([][]int, k+1)
		currLen := make([][]int, k+1)
		for x := 0; x <= k; x++ {
			prevLen[x] = make([]int, m+1)
			currLen[x] = make([]int, m+1)
		}

		for j := 1; j <= m; j++ {
			for x := 1; x <= k; x++ {
				if s[i-1] == t[j-1] {
					v := max(dp[x-1][j-1], prevLen[x][j-1]) + 1
					currLen[x][j] = v
				} else {
					currLen[x][j] = 0
				}
			}
			for x := 1; x <= k; x++ {
				if currLen[x][j] > newdp[x][j] {
					newdp[x][j] = currLen[x][j]
				}
				if newdp[x][j-1] > newdp[x][j] {
					newdp[x][j] = newdp[x][j-1]
				}
				if newdp[x][j] > newdp[x][j] {
					newdp[x][j] = newdp[x][j]
				}
			}
		}

		for x := 0; x <= k; x++ {
			for j := 1; j <= m; j++ {
				if newdp[x][j] < newdp[x][j-1] {
					newdp[x][j] = newdp[x][j-1]
				}
			}
		}

		for x := 0; x <= k; x++ {
			for j := 0; j <= m; j++ {
				dp[x][j] = newdp[x][j]
			}
		}

		for x := 0; x <= k; x++ {
			_ = prevLen[x]
		}
		_ = currLen
	}

	fmt.Println(dp[k][m])
}
```