For problem statement at 0-999/100-199/120-129/120/problemH.txt this is a correct solution, but verifier at 0-999/100-199/120-129/120/verifierH.go ends with test 1 failed
input:
2
bwpbd
gqfc
expected:actual:b
g
exit status 1 can you fix the verifier? ```go
package main
import (
"bufio"
"fmt"
"math/bits"
"os"
"strings"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
n := 0
fmt.Sscanf(scanner.Text(), "%d", &n)
words := make([]string, n)
for i := 0; i < n; i++ {
scanner.Scan()
words[i] = strings.TrimSpace(scanner.Text())
}
strToID := make(map[string]int)
idToStr := []string{}
adj := make([][]int, n)
for i, w := range words {
m := len(w)
seen := make(map[string]struct{})
for mask := 1; mask < (1 << m); mask++ {
cnt := bits.OnesCount(uint(mask))
if cnt < 1 || cnt > 4 {
continue
}
b := make([]byte, 0, 4)
for j := 0; j < m; j++ {
if mask&(1<<j) != 0 {
b = append(b, w[j])
}
}
s := string(b)
if _, ok := seen[s]; ok {
continue
}
seen[s] = struct{}{}
id, ok := strToID[s]
if !ok {
id = len(idToStr)
strToID[s] = id
idToStr = append(idToStr, s)
}
adj[i] = append(adj[i], id)
}
}
m := len(idToStr)
matchL := make([]int, n)
matchR := make([]int, m)
for i := range matchL {
matchL[i] = -1
}
for i := range matchR {
matchR[i] = -1
}
var dfs func(int, []bool) bool
dfs = func(v int, visited []bool) bool {
for _, u := range adj[v] {
if visited[u] {
continue
}
visited[u] = true
if matchR[u] == -1 || dfs(matchR[u], visited) {
matchL[v] = u
matchR[u] = v
return true
}
}
return false
}
for i := 0; i < n; i++ {
visited := make([]bool, m)
if !dfs(i, visited) {
fmt.Println(-1)
return
}
}
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
for i := 0; i < n; i++ {
fmt.Fprintln(out, idToStr[matchL[i]])
}
}
```