← Home
For problem statement at 0-999/300-399/350-359/357/problemB.txt this is a correct solution, but verifier at 0-999/300-399/350-359/357/verifierB.go ends with case 1 failed
expected: 1 3 2 3 1 1
 got: 3 1 2 3 1 3
exit status 1 can you fix the verifier? package main

import (
	"bufio"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanInt := func() int {
		scanner.Scan()
		val, _ := strconv.Atoi(scanner.Text())
		return val
	}

	if !scanner.Scan() {
		return
	}
	n, _ := strconv.Atoi(scanner.Text())
	m := scanInt()

	colors := make([]int, n+1)

	for i := 0; i < m; i++ {
		a := scanInt()
		b := scanInt()
		c := scanInt()

		if colors[a] != 0 {
			colors[b] = (colors[a]%3) + 1
			colors[c] = (colors[b]%3) + 1
		} else if colors[b] != 0 {
			colors[a] = (colors[b]%3) + 1
			colors[c] = (colors[a]%3) + 1
		} else if colors[c] != 0 {
			colors[a] = (colors[c]%3) + 1
			colors[b] = (colors[a]%3) + 1
		} else {
			colors[a] = 1
			colors[b] = 2
			colors[c] = 3
		}
	}

	writer := bufio.NewWriter(os.Stdout)
	for i := 1; i <= n; i++ {
		writer.WriteString(strconv.Itoa(colors[i]))
		if i < n {
			writer.WriteByte(' ')
		}
	}
	writer.WriteByte('\n')
	writer.Flush()
}