← Home
For problem statement at 0-999/500-599/540-549/547/problemD.txt this is a correct solution, but verifier at 0-999/500-599/540-549/547/verifierD.go ends with All 100 tests passed can you fix the verifier? package main

import (
	"fmt"
	"io"
	"os"
)

const MAXC = 200005

type Edge struct {
	to int
	id int
}

func main() {
	input, _ := io.ReadAll(os.Stdin)
	pos := 0

	nextInt := func() int {
		for pos < len(input) && (input[pos] < '0' || input[pos] > '9') {
			pos++
		}
		if pos >= len(input) {
			return 0
		}
		res := 0
		for pos < len(input) && input[pos] >= '0' && input[pos] <= '9' {
			res = res*10 + int(input[pos]-'0')
			pos++
		}
		return res
	}

	n := nextInt()
	if n == 0 {
		return
	}

	adj := make([][]Edge, 2*MAXC)
	degree := make([]int, 2*MAXC)

	for i := 0; i < n; i++ {
		x := nextInt()
		y := nextInt()
		y += MAXC
		adj[x] = append(adj[x], Edge{y, i})
		adj[y] = append(adj[y], Edge{x, i})
		degree[x]++
		degree[y]++
	}

	edgeID := n
	for i := 1; i < 2*MAXC; i++ {
		if degree[i]%2 != 0 {
			adj[i] = append(adj[i], Edge{0, edgeID})
			adj[0] = append(adj[0], Edge{i, edgeID})
			edgeID++
		}
	}

	used := make([]bool, edgeID)
	ans := make([]byte, n)
	head := make([]int, 2*MAXC)

	var dfs func(int)
	dfs = func(u int) {
		for head[u] < len(adj[u]) {
			e := adj[u][head[u]]
			head[u]++
			if !used[e.id] {
				used[e.id] = true
				dfs(e.to)
				if e.id < n {
					if u < MAXC {
						ans[e.id] = 'r'
					} else {
						ans[e.id] = 'b'
					}
				}
			}
		}
	}

	for i := 0; i < 2*MAXC; i++ {
		dfs(i)
	}

	fmt.Println(string(ans))
}