← Home
For problem statement at 0-999/900-999/990-999/995/problemA.txt this is a correct solution, but verifier at 0-999/900-999/990-999/995/verifierA.go ends with  can you fix the verifier? ```go
package main

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

type Pos struct {
	r, c int
}

type Move struct {
	id, r, c int
}

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

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

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

	targets := make([]Pos, k+1)

	for c := 1; c <= n; c++ {
		x := readInt()
		if x > 0 {
			targets[x] = Pos{1, c}
		}
	}

	board := make([][]int, 5)
	for i := range board {
		board[i] = make([]int, n+1)
	}

	for c := 1; c <= n; c++ {
		board[2][c] = readInt()
	}

	for c := 1; c <= n; c++ {
		board[3][c] = readInt()
	}

	for c := 1; c <= n; c++ {
		x := readInt()
		if x > 0 {
			targets[x] = Pos{4, c}
		}
	}

	var ring []Pos
	for c := 1; c <= n; c++ {
		ring = append(ring, Pos{2, c})
	}
	for c := n; c >= 1; c-- {
		ring = append(ring, Pos{3, c})
	}

	var moves []Move
	parkedCount := 0

	for {
		parkedInThisIteration := true
		for parkedInThisIteration {
			parkedInThisIteration = false
			for c := 1; c <= n; c++ {
				car2 := board[2][c]
				if car2 > 0 && targets[car2].r == 1 && targets[car2].c == c {
					moves = append(moves, Move{car2, 1, c})
					board[1][c] = car2
					board[2][c] = 0
					parkedInThisIteration = true
					parkedCount++
				}
				car3 := board[3][c]
				if car3 > 0 && targets[car3].r == 4 && targets[car3].c == c {
					moves = append(moves, Move{car3, 4, c})
					board[4][c] = car3
					board[3][c] = 0
					parkedInThisIteration = true
					parkedCount++
				}
			}
		}

		if parkedCount == k {
			break
		}

		idx := -1
		for i := 0; i < 2*n; i++ {
			if board[ring[i].r][ring[i].c] == 0 {
				idx = i
				break
			}
		}

		if idx == -1 {
			fmt.Println("-1")
			return
		}

		for step := 1; step < 2*n; step++ {
			curr := (idx - step + 2*n) % (2 * n)
			next := (curr + 1) % (2 * n)
			currR, currC := ring[curr].r, ring[curr].c
			nextR, nextC := ring[next].r, ring[next].c

			if board[currR][currC] > 0 && board[nextR][nextC] == 0 {
				moves = append(moves, Move{board[currR][currC], nextR, nextC})
				board[nextR][nextC] = board[currR][currC]
				board[currR][currC] = 0
			}
		}
	}

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

	fmt.Fprintln(writer, len(moves))
	for _, m := range moves {
		fmt.Fprintf(writer, "%d %d %d\n", m.id, m.r, m.c)
	}
}
```