← Home
For problem statement at 2000-2999/2100-2199/2140-2149/2148/problemC.txt this is a correct solution, but verifier at 2000-2999/2100-2199/2140-2149/2148/verifierC.go ends with All 8 tests passed. can you fix the verifier? package main

import (
	"bytes"
	"io"
	"os"
	"strconv"
)

func main() {
	data, _ := io.ReadAll(os.Stdin)
	idx := 0
	nextInt := func() int64 {
		for idx < len(data) && data[idx] <= ' ' {
			idx++
		}
		var v int64
		for idx < len(data) && data[idx] > ' ' {
			v = v*10 + int64(data[idx]-'0')
			idx++
		}
		return v
	}

	t := int(nextInt())
	var out bytes.Buffer

	for ; t > 0; t-- {
		n := int(nextInt())
		m := nextInt()

		var prevA, prevB, ans int64

		for i := 0; i < n; i++ {
			a := nextInt()
			b := nextInt()
			l := a - prevA
			need := prevB ^ b
			if (l & 1) == need {
				ans += l
			} else {
				ans += l - 1
			}
			prevA = a
			prevB = b
		}

		ans += m - prevA
		out.WriteString(strconv.FormatInt(ans, 10))
		out.WriteByte('\n')
	}

	os.Stdout.Write(out.Bytes())
}