← Home
For problem statement at 0-999/800-899/800-809/802/problemH.txt this is a correct solution, but verifier at 0-999/800-899/800-809/802/verifierH.go ends with All 100 tests passed. can you fix the verifier? package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int64
	if _, err := fmt.Fscan(in, &n); err != nil {
		return
	}

	T := make([]int64, 201)
	for a := 3; a <= 200; a++ {
		x := int64(a)
		T[a] = x * (x - 1) * (x - 2) / 6
	}

	var bestList []int
	found := false

	for highA := 3; highA <= 200; highA++ {
		rem := n
		list := make([]int, 0)
		usedMax := 0
		for a := highA; a >= 3; a-- {
			ta := T[a]
			if ta == 0 || ta > rem {
				continue
			}
			cnt := rem / ta
			if cnt > 0 {
				if usedMax == 0 {
					usedMax = a
				}
				for i := int64(0); i < cnt; i++ {
					list = append(list, a)
				}
				rem -= cnt * ta
			}
			if rem == 0 {
				break
			}
		}
		if rem == 0 {
			if usedMax == 0 {
				usedMax = 3
			}
			if len(list)+usedMax <= 200 {
				bestList = list
				found = true
				break
			}
		}
	}

	if !found {
		fmt.Println("ab a")
		return
	}

	sort.Ints(bestList)

	var s []byte
	curA := 0
	for _, a := range bestList {
		for curA < a {
			s = append(s, 'a')
			curA++
		}
		s = append(s, 'b')
	}

	p := []byte{'a', 'a', 'a', 'b'}

	w := bufio.NewWriter(os.Stdout)
	fmt.Fprintf(w, "%s %s\n", string(s), string(p))
	w.Flush()
}