← Home
For problem statement at 1000-1999/1600-1699/1610-1619/1618/problemF.txt this is a correct solution, but verifier at 1000-1999/1600-1699/1610-1619/1618/verifierF.go ends with All tests passed can you fix the verifier? package main

import (
	"fmt"
	"strings"
)

func reverse(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

func check(t, base string, minA, minB int) bool {
	n := len(t)
	m := len(base)
	if n < m+minA+minB {
		return false
	}
	for i := 0; i <= n-m; i++ {
		if i < minA || n-i-m < minB {
			continue
		}
		if t[i:i+m] == base {
			ok := true
			for j := 0; j < i; j++ {
				if t[j] != '1' {
					ok = false
					break
				}
			}
			if !ok {
				continue
			}
			for j := i + m; j < n; j++ {
				if t[j] != '1' {
					ok = false
					break
				}
			}
			if ok {
				return true
			}
		}
	}
	return false
}

func main() {
	var x, y uint64
	if _, err := fmt.Scan(&x, &y); err != nil {
		return
	}
	if x == y {
		fmt.Println("YES")
		return
	}

	s := fmt.Sprintf("%b", x)
	t := fmt.Sprintf("%b", y)

	sPrime := strings.TrimRight(s, "0")
	revS := reverse(s)
	revSPrime := reverse(sPrime)

	if check(t, s, 0, 1) || check(t, revS, 1, 0) || check(t, sPrime, 0, 0) || check(t, revSPrime, 0, 0) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}