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
    태그
    제출 기록
    1938
    맞았습니다.
    265
    아이디