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 comments

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

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

    • 1

    Information

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