← Home
For problem statement at 1000-1999/1700-1799/1730-1739/1732/problemB.txt this is a correct solution, but verifier at 1000-1999/1700-1799/1730-1739/1732/verifierB.go ends with All tests passed can you fix the verifier? package main

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

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

	var t int
	if _, err := fmt.Fscan(in, &t); err != nil {
		return
	}

	for i := 0; i < t; i++ {
		var n int
		var s string
		fmt.Fscan(in, &n, &s)

		if n == 0 || len(s) == 0 {
			continue
		}

		s1 := int(s[0] - '0')
		S := 0
		for j := 1; j < n; j++ {
			if s[j] != s[j-1] {
				S++
			}
		}

		ans := s1 + S - 1
		if ans < 0 {
			ans = 0
		}
		fmt.Fprintln(out, ans)
	}
}