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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	rec := [4000005][26]int{}
	tag := [4000005]bool{}
	cnt := 0
	for n != 0 {
		scanner.Scan()
		n -= 1
		p := 0
		for _, ch := range scanner.Text() {
			i := ch - 'a'
			if rec[p][i] == 0 {
				cnt += 1
				rec[p][i] = cnt
			}
			p = rec[p][i]
		}
		tag[p] = true
	}
	res := 0
	for _, v := range tag {
		if v {
			res += 1
		}
	}
	fmt.Println(res)
}

同样的思路用C++是对的,换 Go 就 #1-1 报错:Wrong Answer 读取到 2,应为 1。 #1-1 输入是啥啊 =_=

1 comments

  • @ 2023-7-12 18:43:22

    Scanner 和你的预期行为有所不同,他并不和 C++ 的字符串读入相同。

    😄 3
    • 1

    Information

    ID
    180
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    2004
    Accepted
    276
    Uploaded By