← Home
For problem statement at 2000-2999/2100-2199/2130-2139/2138/problemA.txt this is a correct solution, but verifier at 2000-2999/2100-2199/2130-2139/2138/verifierA.go ends with All 44 tests passed. can you fix the verifier? package main

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

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

	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var k uint
		var x uint64
		fmt.Fscan(in, &k, &x)

		base := uint64(1) << k
		cur := x
		ops := make([]int, 0, 64)

		for cur != base {
			if cur < base {
				ops = append(ops, 1)
				cur <<= 1
			} else {
				ops = append(ops, 2)
				cur = (cur - base) << 1
			}
		}

		n := len(ops)
		fmt.Fprintln(out, n)
		for i := n - 1; i >= 0; i-- {
			if i != n-1 {
				fmt.Fprint(out, " ")
			}
			fmt.Fprint(out, ops[i])
		}
		fmt.Fprintln(out)
	}
}