← Home
For problem statement at 0-999/700-799/750-759/757/problemC.txt this is a correct solution, but verifier at 0-999/700-799/750-759/757/verifierC.go ends with All tests passed can you fix the verifier? ```go
package main

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

const mod = 1000000007
const maxm = 1000000

type pair struct {
	gym int
	cnt int
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	readInt := func() int {
		scanner.Scan()
		i, _ := strconv.Atoi(scanner.Text())
		return i
	}

	n := readInt()
	m := readInt()

	profiles := make([][]pair, m+1)
	var appearing []int

	for gym := 1; gym <= n; gym++ {
		gi := readInt()
		typeList := make([]int, gi)
		for j := 0; j < gi; j++ {
			typeList[j] = readInt()
		}
		sort.Ints(typeList)
		for j := 0; j < gi; {
			t := typeList[j]
			cnt := 1
			j++
			for ; j < gi && typeList[j] == t; j++ {
				cnt++
			}
			profiles[t] = append(profiles[t], pair{gym, cnt})
			if len(profiles[t]) == 1 {
				appearing = append(appearing, t)
			}
		}
	}

	k := len(appearing)
	numZero := m - k

	fact := make([]int64, maxm+1)
	fact[0] = 1
	for i := 1; i <= maxm; i++ {
		fact[i] = fact[i-1] * int64(i) % mod
	}

	type hashKey struct {
		h1, h2 uint64
	}
	groups := make(map[hashKey]int)

	for _, t := range appearing {
		h1, h2 := hashProfile(profiles[t])
		key := hashKey{h1, h2}
		groups[key]++
	}

	ans := int64(1)
	if numZero > 0 {
		ans = ans * fact[numZero] % mod
	}
	for _, s := range groups {
		ans = ans * fact[s] % mod
	}

	fmt.Println(ans)
}

func hashProfile(p []pair) (uint64, uint64) {
	var h1, h2 uint64
	for _, pr := range p {
		h1 = h1*179 + uint64(pr.gym)
		h1 = h1*179 + uint64(pr.cnt)
		h2 = h2*181 + uint64(pr.gym)
		h2 = h2*181 + uint64(pr.cnt)
	}
	return h1, h2
}
```