← Home
For problem statement at 0-999/300-399/340-349/345/problemF.txt this is a correct solution, but verifier at 0-999/300-399/340-349/345/verifierF.go ends with All tests passed can you fix the verifier? package main

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

func normalize(s string) string {
	return strings.ToLower(strings.Join(strings.Fields(s), " "))
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var lines []string
	for scanner.Scan() {
		lines = append(lines, scanner.Text())
	}

	counts := make(map[string]int)
	seenInCountry := make(map[string]bool)

	for _, line := range lines {
		if strings.HasPrefix(line, "* ") {
			name := normalize(line[2:])
			if !seenInCountry[name] {
				seenInCountry[name] = true
				counts[name]++
			}
		} else {
			seenInCountry = make(map[string]bool)
		}
	}

	maxCount := 0
	for _, c := range counts {
		if c > maxCount {
			maxCount = c
		}
	}

	var ans []string
	for name, c := range counts {
		if c == maxCount {
			ans = append(ans, name)
		}
	}

	sort.Strings(ans)

	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	for _, s := range ans {
		fmt.Fprintln(out, s)
	}
}