← Home
For problem statement at 0-999/500-599/570-579/570/problemC.txt this is a correct solution, but verifier at 0-999/500-599/570-579/570/verifierC.go ends with All tests passed can you fix the verifier? package main

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

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

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

	var sStr string
	fmt.Fscan(reader, &sStr)
	s := []byte(sStr)

	ans := 0
	for i := 0; i < n-1; i++ {
		if s[i] == '.' && s[i+1] == '.' {
			ans++
		}
	}

	for i := 0; i < m; i++ {
		var x int
		var cStr string
		fmt.Fscan(reader, &x, &cStr)
		x--
		c := cStr[0]

		if s[x] == '.' && c != '.' {
			if x > 0 && s[x-1] == '.' {
				ans--
			}
			if x < n-1 && s[x+1] == '.' {
				ans--
			}
		} else if s[x] != '.' && c == '.' {
			if x > 0 && s[x-1] == '.' {
				ans++
			}
			if x < n-1 && s[x+1] == '.' {
				ans++
			}
		}
		s[x] = c
		fmt.Fprintln(writer, ans)
	}
}