← Home
For problem statement at 1000-1999/1800-1899/1840-1849/1840/problemE.txt this is a correct solution, but verifier at 1000-1999/1800-1899/1840-1849/1840/verifierE.go ends with All tests passed can you fix the verifier? package main

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

type Block struct {
	time int
	pos  int
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 1024*1024), 10*1024*1024)
	scanner.Split(bufio.ScanWords)

	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	next := func() string {
		scanner.Scan()
		return scanner.Text()
	}

	nextInt := func() int {
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		return n
	}

	if !scanner.Scan() {
		return
	}
	T, _ := strconv.Atoi(scanner.Text())

	for tc := 0; tc < T; tc++ {
		s1 := []byte(next())
		s2 := []byte(next())
		tSec := nextInt()
		q := nextInt()

		s := [][]byte{s1, s2}
		diffCount := 0
		for i := 0; i < len(s[0]); i++ {
			if s[0][i] != s[1][i] {
				diffCount++
			}
		}

		queue := make([]Block, 0)
		head := 0

		for i := 1; i <= q; i++ {
			for head < len(queue) && queue[head].time == i {
				p := queue[head].pos
				if s[0][p] != s[1][p] {
					diffCount++
				}
				head++
			}

			typ := nextInt()
			if typ == 1 {
				pos := nextInt() - 1
				if s[0][pos] != s[1][pos] {
					diffCount--
				}
				queue = append(queue, Block{i + tSec, pos})
			} else if typ == 2 {
				c1 := nextInt() - 1
				pos1 := nextInt() - 1
				c2 := nextInt() - 1
				pos2 := nextInt() - 1

				if pos1 != pos2 {
					if s[0][pos1] != s[1][pos1] {
						diffCount--
					}
					if s[0][pos2] != s[1][pos2] {
						diffCount--
					}
					s[c1][pos1], s[c2][pos2] = s[c2][pos2], s[c1][pos1]
					if s[0][pos1] != s[1][pos1] {
						diffCount++
					}
					if s[0][pos2] != s[1][pos2] {
						diffCount++
					}
				} else {
					if s[0][pos1] != s[1][pos1] {
						diffCount--
					}
					s[c1][pos1], s[c2][pos2] = s[c2][pos2], s[c1][pos1]
					if s[0][pos1] != s[1][pos1] {
						diffCount++
					}
				}
			} else if typ == 3 {
				if diffCount == 0 {
					fmt.Fprintln(out, "YES")
				} else {
					fmt.Fprintln(out, "NO")
				}
			}
		}
	}
}