← Home
For problem statement at 1000-1999/1000-1099/1090-1099/1095/problemD.txt this is a correct solution, but verifier at 1000-1999/1000-1099/1090-1099/1095/verifierD.go ends with case 1 failed: runtime error: exit status 2
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
main.main()
	/tmp/build-3361041849/solution.go:60 +0x494

input:
9
3 2
3 4
4 5
6 5
6 7
8 7
9 8
9 1
1 2
exit status 1 can you fix the verifier? ```go
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(in, &n)
	rem := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		var a, b int
		fmt.Fscan(in, &a, &b)
		rem[i] = []int{a, b}
	}
	start := 1
	var ans []int
	for choice := 0; choice < 2; choice++ {
		order := []int{}
		visited := make([]bool, n+1)
		current := start
		order = append(order, current)
		visited[current] = true
		next_succ := rem[start][choice]
		ok := true
		for i := 0; i < n; i++ {
			if visited[next_succ] {
				if next_succ == start && len(order) == n {
					ans = order
					ok = true
					break
				} else {
					ok = false
					break
				}
			}
			order = append(order, next_succ)
			visited[next_succ] = true
			previous := current
			current = next_succ
			var other int
			if rem[current][0] == previous {
				other = rem[current][1]
			} else {
				other = rem[current][0]
			}
			next_succ = other
		}
		if ok && len(order) == n {
			break
		}
	}
	for i := 0; i < n; i++ {
		if i > 0 {
			fmt.Print(" ")
		}
		fmt.Print(ans[i])
	}
	fmt.Println()
}
```