← Home
For problem statement at 1000-1999/1200-1299/1280-1289/1286/problemB.txt this is a correct solution, but verifier at 1000-1999/1200-1299/1280-1289/1286/verifierB.go ends with All tests passed can you fix the verifier? ```go
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 n int
	if _, err := fmt.Fscan(in, &n); err != nil {
		return
	}

	children := make([][]int, n+1)
	c := make([]int, n+1)
	root := 0

	for i := 1; i <= n; i++ {
		var p int
		fmt.Fscan(in, &p, &c[i])
		if p == 0 {
			root = i
		} else {
			children[p] = append(children[p], i)
		}
	}

	impossible := false

	var dfs func(int) []int
	dfs = func(u int) []int {
		order := make([]int, 0)
		for _, v := range children[u] {
			sub := dfs(v)
			if impossible {
				return nil
			}
			order = append(order, sub...)
		}
		if c[u] > len(order) {
			impossible = true
			return nil
		}
		res := make([]int, 0, len(order)+1)
		res = append(res, order[:c[u]]...)
		res = append(res, u)
		res = append(res, order[c[u]:]...)
		return res
	}

	order := dfs(root)
	if impossible {
		fmt.Fprintln(out, "NO")
		return
	}

	ans := make([]int, n+1)
	for i, v := range order {
		ans[v] = i + 1
	}

	fmt.Fprintln(out, "YES")
	for i := 1; i <= n; i++ {
		if i > 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, ans[i])
	}
	fmt.Fprintln(out)
}
```