For problem statement at 0-999/800-899/850-859/858/problemE.txt this is a correct solution, but verifier at 0-999/800-899/850-859/858/verifierE.go ends with case 1 failed
expected: 10
move 3di 5
move 7w3fv7 4
move l72r 3
move fgn 2
move 7qgdyf 1
move 5o 10
move lzqlkf 9
move hz 8
move 5jjd 7
move lk9k4p 6
got: 15
move 5o tmp
move 3di 5o
move tmp 3di
move lzqlkf tmp
move 7w3fv7 lzqlkf
move tmp 7w3fv7
move hz tmp
move l72r hz
move tmp l72r
move 5jjd tmp
move fgn 5jjd
move tmp fgn
move lk9k4p tmp
move 7qgdyf lk9k4p
move tmp 7qgdyf
exit status 1 can you fix the verifier? ```go
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
scanner.Scan()
n, _ := strconv.Atoi(scanner.Text())
type file struct {
name string
t int
}
files := make([]file, n)
nameSet := make(map[string]bool)
cnt1 := 0
for i := 0; i < n; i++ {
scanner.Scan()
name := scanner.Text()
scanner.Scan()
t, _ := strconv.Atoi(scanner.Text())
files[i] = file{name, t}
nameSet[name] = true
if t == 1 {
cnt1++
}
}
tmp := "tmp"
for nameSet[tmp] {
tmp += "x"
}
isNum := func(s string) (int, bool) {
if len(s) == 0 || len(s) > 6 {
return 0, false
}
for i := 0; i < len(s); i++ {
if s[i] < '0' || s[i] > '9' {
return 0, false
}
}
if s[0] == '0' && len(s) > 1 {
return 0, false
}
num, err := strconv.Atoi(s)
if err != nil || num < 1 || num > n {
return 0, false
}
return num, true
}
bad1 := []string{}
bad0 := []string{}
g1 := []string{}
g0 := []string{}
for i := 1; i <= cnt1; i++ {
s := strconv.Itoa(i)
if !nameSet[s] {
g1 = append(g1, s)
}
}
for i := cnt1 + 1; i <= n; i++ {
s := strconv.Itoa(i)
if !nameSet[s] {
g0 = append(g0, s)
}
}
for _, f := range files {
num, ok := isNum(f.name)
if !ok {
if f.t == 1 {
bad1 = append(bad1, f.name)
} else {
bad0 = append(bad0, f.name)
}
continue
}
if f.t == 1 {
if num > cnt1 {
bad1 = append(bad1, f.name)
}
} else {
if num <= cnt1 {
bad0 = append(bad0, f.name)
}
}
}
var moves [][2]string
for len(bad1) > 0 && len(bad0) > 0 {
f1 := bad1[len(bad1)-1]
bad1 = bad1[:len(bad1)-1]
f0 := bad0[len(bad0)-1]
bad0 = bad0[:len(bad0)-1]
moves = append(moves, [2]string{f0, tmp})
moves = append(moves, [2]string{f1, f0})
moves = append(moves, [2]string{tmp, f1})
}
for _, f := range bad1 {
slot := g1[len(g1)-1]
g1 = g1[:len(g1)-1]
moves = append(moves, [2]string{f, slot})
}
for _, f := range bad0 {
slot := g0[len(g0)-1]
g0 = g0[:len(g0)-1]
moves = append(moves, [2]string{f, slot})
}
fmt.Println(len(moves))
for _, m := range moves {
fmt.Printf("move %s %s\n", m[0], m[1])
}
}
```