For problem statement at 1000-1999/1400-1499/1420-1429/1422/problemE.txt this is a correct solution, but verifier at 1000-1999/1400-1499/1420-1429/1422/verifierE.go ends with Wrong answer on test 11
Input:cbacbaac
Expected:8 cbacb
7 bacba
6 acbaa
5 cbaac
4 baac
3 aac
2 ac
1 c
Got:8 cbacbaac
7 bacbaac
6 acbaac
5 cbaac
4 baac
3 aac
2 ac
1 c
exit status 1 can you fix the verifier? ```go
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
reader := bufio.NewReaderSize(os.Stdin, 1024*1024)
line, _ := reader.ReadString('\n')
s := strings.TrimSpace(line)
n := len(s)
type state struct {
length int
prefix string
suffix string
first byte
diff byte
}
dp := make([]state, n+2)
for i := n - 1; i >= 0; i-- {
// Calculate the 'Keep' candidate: s[i] + dp[i+1]
keep := state{}
keep.length = 1 + dp[i+1].length
keep.first = s[i]
if dp[i+1].length == 0 {
keep.diff = 0
} else if dp[i+1].first != s[i] {
keep.diff = dp[i+1].first
} else {
keep.diff = dp[i+1].diff
}
if dp[i+1].length <= 10 {
fullStr := string(s[i]) + dp[i+1].prefix
if len(fullStr) > 10 {
keep.prefix = fullStr[:5]
keep.suffix = fullStr[len(fullStr)-2:]
} else {
keep.prefix = fullStr
keep.suffix = ""
}
} else {
keep.prefix = string(s[i]) + dp[i+1].prefix[:4]
keep.suffix = dp[i+1].suffix
}
takeDelete := false
// Check if we can form a pair and if deleting is optimal
if i+1 < n && s[i] == s[i+1] {
x := byte(0)
if dp[i+2].length > 0 {
if dp[i+2].first != s[i] {
x = dp[i+2].first
} else {
x = dp[i+2].diff
}
}
// If s[i] > first different char in dp[i+2], then deleting is better
if s[i] > x {
takeDelete = true
}
}
if takeDelete {
dp[i] = dp[i+2]
} else {
dp[i] = keep
}
}
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
for i := 0; i < n; i++ {
fmt.Fprintf(out, "%d ", dp[i].length)
if dp[i].length <= 10 {
fmt.Fprintln(out, dp[i].prefix)
} else {
fmt.Fprintf(out, "%s...%s\n", dp[i].prefix, dp[i].suffix)
}
}
}
```