← Home
For problem statement at 1000-1999/1100-1199/1110-1119/1118/problemE.txt this is a correct solution, but verifier at 1000-1999/1100-1199/1110-1119/1118/verifierE.go ends with all tests passed can you fix the verifier? ```go
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n, k int
	fmt.Fscan(reader, &n, &k)

	// Total possible pairs: k*(k-1) (pairs where b != g)
	maxPairs := k * (k - 1)
	if n > maxPairs {
		fmt.Fprintln(writer, "NO")
		return
	}

	// Generate pairs such that consecutive pairs differ in both b and g
	// Strategy: generate all pairs in a specific order
	// We'll generate pairs (b, g) where b != g
	// Order them so consecutive ones differ in both coordinates
	
	// Generate pairs grouped by b value
	// For b=1: (1,2),(1,3),...,(1,k)
	// For b=2: (2,1),(2,3),...,(2,k)
	// etc.
	// But consecutive groups might share same b
	
	// Better approach: interleave
	// Think of it as: list all valid pairs in an order where consecutive differ in both b and g
	
	// One approach: 
	// Generate pairs row by row but shift columns
	// Row i (1-indexed): pairs with b=i, g cycles through values != i
	// To ensure consecutive rows don't share g values at the boundary,
	// we need to be careful.
	
	// Let's just generate all pairs and then find a valid ordering.
	// Actually, let's think of a constructive approach.
	
	// Generate pairs in this order:
	// (1,2),(2,3),(3,4),...,(k-1,k),(k,1) - cycle of length k
	// (1,3),(2,4),(3,5),...              - next cycle shifting by 2
	// etc.
	
	// Actually let's use a simpler approach:
	// Generate pairs (i, j) where i != j, ordered such that consecutive differ.
	// 
	// One known construction: list pairs as
	// (1,2),(2,1),(1,3),(3,1),(1,4),(4,1),...
	// but this may repeat g values consecutively
	
	// Let me use a different strategy:
	// Generate pairs in snake order through a k x k grid (excluding diagonal)
	
	pairs := make([][2]int, 0, n)
	
	// Generate pairs grouped: for each "difference" d from 1 to k-1,
	// pairs (b, b+d mod k) for b from 1 to k
	// Within each group, consecutive pairs differ in b (and also in g since g = b+d)
	// Between groups: last pair of group d is (k, k+d mod k), first pair of group d+1 is (1, 1+(d+1) mod k)
	// These differ in b (k vs 1) but we need to check g too.
	
	// Let's just generate and check - for this problem size it should work
	// by generating in a specific order.
	
	// Simple generation: iterate b from 1 to k, for each b iterate g from 1 to k skipping b
	// Then fix adjacency issues by reordering if needed.
	// 
	// Actually the simplest valid construction for the output:
	// Use the sequence: for offset d = 1, 2, ..., k-1:
	//   for b = 1, 2, ..., k: output (b, ((b-1+d) % k) + 1)
	// This gives groups where within group consecutive b's differ and g's differ.
	// Between groups: (k, ((k-1+d)%k)+1) and (1, ((0+d+1)%k)+1)
	// b changes k->1 ok, g: ((k-1+d)%k)+1 vs ((d)%k)+1
	// If d < k-1: (k-1+d)%k = d+k-1 if d+k-1 < k => no, = d-1. So g1 = d, g2 = d+1. Different! Good.
	
	for d := 1; d < k && len(pairs) < n; d++ {
		for b := 1; b <= k && len(pairs) < n; b++ {
			g := ((b-1+d)%k) + 1
			pairs = append(pairs, [2]int{b, g})
		}
	}
	
	fmt.Fprintln(writer, "YES")
	for i := 0; i < n; i++ {
		fmt.Fprintf(writer, "%d %d\n", pairs[i][0], pairs[i][1])
	}
}
```