← Home
For problem statement at 1000-1999/1900-1999/1990-1999/1994/problemD.txt this is a correct solution, but verifier at 1000-1999/1900-1999/1990-1999/1994/verifierD.go ends with case 1 edge mismatch
expected: 1 2
got: 2 1

exit status 1 can you fix the verifier? package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1024*1024), 10*1024*1024)

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

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

	for tc := 0; tc < t; tc++ {
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())

		a := make([]int, n+1)
		for i := 1; i <= n; i++ {
			scanner.Scan()
			a[i], _ = strconv.Atoi(scanner.Text())
		}

		fmt.Fprintln(out, "Yes")

		parent := make([]int, n+1)
		for i := 1; i <= n; i++ {
			parent[i] = i
		}

		var find func(i int) int
		find = func(i int) int {
			if parent[i] == i {
				return i
			}
			parent[i] = find(parent[i])
			return parent[i]
		}

		edges := make([][2]int, n)
		seen := make([]int, n)

		for x := n - 1; x >= 1; x-- {
			for i := 0; i < x; i++ {
				seen[i] = -1
			}

			for i := 1; i <= n; i++ {
				if find(i) == i {
					rem := a[i] % x
					if seen[rem] != -1 {
						edges[x] = [2]int{i, seen[rem]}
						rootU := i
						rootV := seen[rem]
						parent[rootU] = rootV
						break
					} else {
						seen[rem] = i
					}
				}
			}
		}

		for x := 1; x <= n-1; x++ {
			fmt.Fprintln(out, edges[x][0], edges[x][1])
		}
	}
}