← Home
For problem statement at 0-999/800-899/810-819/819/problemE.txt this is a correct solution, but verifier at 0-999/800-899/810-819/819/verifierE.go ends with test 2 failed:
input:8
expected:
16
3 1 2 3
3 2 3 4
3 3 4 1
3 4 1 2
3 5 1 6
3 5 2 6
4 5 1 6 2
4 5 3 6 4
4 5 3 6 4
3 7 1 8
3 7 2 8
4 7 1 8 2
4 7 3 8 4
4 7 3 8 4
4 7 5 8 6
4 7 5 8 6
got:
15
4 1 2 3 4
4 1 2 4 3
4 1 3 2 4
4 5 1 6 2
3 5 6 1
3 5 6 2
4 5 3 6 4
4 5 3 6 4
4 7 1 8 2
3 7 8 1
3 7 8 2
4 7 3 8 4
4 7 3 8 4
4 7 5 8 6
4 7 5 8 6 can you fix the verifier? package main

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

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		return
	}

	var cycles [][]int

	if n%2 == 1 {
		cycles = append(cycles, []int{3, 1, 2, 3})
		cycles = append(cycles, []int{3, 1, 2, 3})
		for curr := 3; curr < n; curr += 2 {
			u := curr + 1
			v := curr + 2
			cycles = append(cycles, []int{3, u, v, 1})
			cycles = append(cycles, []int{3, u, v, 1})
			for i := 2; i <= curr; i += 2 {
				cycles = append(cycles, []int{4, u, i, v, i + 1})
				cycles = append(cycles, []int{4, u, i, v, i + 1})
			}
		}
	} else {
		cycles = append(cycles, []int{4, 1, 2, 3, 4})
		cycles = append(cycles, []int{4, 1, 2, 4, 3})
		cycles = append(cycles, []int{4, 1, 3, 2, 4})
		for curr := 4; curr < n; curr += 2 {
			u := curr + 1
			v := curr + 2
			cycles = append(cycles, []int{4, u, 1, v, 2})
			cycles = append(cycles, []int{3, u, v, 1})
			cycles = append(cycles, []int{3, u, v, 2})
			for i := 3; i <= curr; i += 2 {
				cycles = append(cycles, []int{4, u, i, v, i + 1})
				cycles = append(cycles, []int{4, u, i, v, i + 1})
			}
		}
	}

	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	fmt.Fprintln(out, len(cycles))
	for _, c := range cycles {
		for i, x := range c {
			if i > 0 {
				fmt.Fprint(out, " ")
			}
			fmt.Fprint(out, x)
		}
		fmt.Fprintln(out)
	}
}