← Home
For problem statement at 1000-1999/1300-1399/1360-1369/1362/problemB.txt this is a correct solution, but verifier at 1000-1999/1300-1399/1360-1369/1362/verifierB.go ends with all 103 tests passed can you fix the verifier? package main

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

type FastScanner struct {
	r *bufio.Reader
}

func NewFastScanner() *FastScanner {
	return &FastScanner{r: bufio.NewReaderSize(os.Stdin, 1<<20)}
}

func (fs *FastScanner) NextInt() int {
	sign, val := 1, 0
	c, _ := fs.r.ReadByte()
	for (c < '0' || c > '9') && c != '-' {
		c, _ = fs.r.ReadByte()
	}
	if c == '-' {
		sign = -1
		c, _ = fs.r.ReadByte()
	}
	for c >= '0' && c <= '9' {
		val = val*10 + int(c-'0')
		c2, err := fs.r.ReadByte()
		if err != nil {
			break
		}
		c = c2
		if c < '0' || c > '9' {
			break
		}
	}
	return sign * val
}

func main() {
	in := NewFastScanner()
	out := bufio.NewWriterSize(os.Stdout, 1<<20)
	defer out.Flush()

	t := in.NextInt()
	for ; t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		present := make([]bool, 1024)
		for i := 0; i < n; i++ {
			x := in.NextInt()
			a[i] = x
			present[x] = true
		}

		ans := -1
		for k := 1; k < 1024; k++ {
			ok := true
			for _, x := range a {
				if !present[x^k] {
					ok = false
					break
				}
			}
			if ok {
				ans = k
				break
			}
		}
		fmt.Fprintln(out, ans)
	}
}