use std::io::stdin;
use std::str::FromStr;
use std::collections::HashSet;

fn main() {
    let mut len_lines = read::<i32>();
    let mut set = HashSet::new();
    let sin = stdin();
    while len_lines > 0 {
        let mut s = String::new();
        sin.read_line(&mut s).unwrap();
        set.insert(s);
        len_lines -= 1;
    }
    println!("{}", set.len());
}

fn read<T: FromStr>() -> T {
    let mut tmp = String::new();
    stdin().read_line(&mut tmp).unwrap();
    match tmp.trim().parse::<T>() {
        Ok(p) => p,
        Err(_e) => panic!(),
    }
}

1 条评论

  • @ 2023-4-13 10:26:07

    @ 这题叫字典树,卡掉 hashmap 是很正常的。

    • 1

    信息

    ID
    180
    时间
    1000ms
    内存
    256MiB
    难度
    3
    标签
    递交数
    1871
    已通过
    261
    上传者