結果

問題 No.2714 Amaou
ユーザー ktmtr005ktmtr005
提出日時 2024-04-08 22:40:08
言語 Rust
(1.77.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 6,855 bytes
コンパイル時間 11,773 ms
コンパイル使用メモリ 377,540 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-01 13:32:36
合計ジャッジ時間 13,084 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,248 KB
testcase_02 AC 0 ms
5,248 KB
testcase_03 AC 0 ms
5,248 KB
testcase_04 AC 1 ms
5,248 KB
testcase_05 AC 1 ms
5,248 KB
testcase_06 AC 0 ms
5,248 KB
testcase_07 AC 1 ms
5,248 KB
testcase_08 AC 1 ms
5,248 KB
testcase_09 AC 1 ms
5,248 KB
testcase_10 AC 1 ms
5,248 KB
testcase_11 AC 1 ms
5,248 KB
testcase_12 AC 1 ms
5,248 KB
testcase_13 AC 1 ms
5,248 KB
testcase_14 AC 1 ms
5,248 KB
testcase_15 AC 1 ms
5,248 KB
testcase_16 AC 0 ms
5,248 KB
testcase_17 AC 1 ms
5,248 KB
testcase_18 AC 1 ms
5,248 KB
testcase_19 AC 0 ms
5,248 KB
testcase_20 AC 1 ms
5,248 KB
testcase_21 AC 1 ms
5,248 KB
testcase_22 AC 1 ms
5,248 KB
testcase_23 AC 1 ms
5,248 KB
testcase_24 AC 1 ms
5,248 KB
testcase_25 AC 1 ms
5,248 KB
testcase_26 AC 1 ms
5,248 KB
testcase_27 AC 1 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashSet;

use lib::io::Scanner;

fn main() {
    let mut sc = Scanner::new(std::io::stdin().lock());
    let n: usize = sc.next();
    let s: Vec<HashSet<String>> = (0..n)
        .map(|_| {
            (0..4)
                .map(|_| sc.next::<String>())
                .collect::<HashSet<String>>()
        })
        .collect();

    let ans = solve(s);
    bufwriteln!("{ans}");
}

fn solve(s: Vec<HashSet<String>>) -> usize {
    let amaou: HashSet<String> = HashSet::from([
        "akai".to_string(),
        "marui".to_string(),
        "okii".to_string(),
        "umai".to_string(),
    ]);
    s.iter().filter(|&x| x == &amaou).count()
}

// https://github.com/ktmtr005/competitive-rust-library

#[allow(dead_code)]
pub mod lib {
    pub mod io {
        pub struct Scanner<R: std::io::BufRead> {
            reader: R,
            buf: Vec<u8>,
            pos: usize,
        }

        impl<R: std::io::BufRead> Scanner<R> {
            pub fn new(reader: R) -> Self {
                Scanner {
                    reader,
                    buf: Vec::new(),
                    pos: 0,
                }
            }

            pub fn with_capacity(reader: R, capacity: usize) -> Self {
                Scanner {
                    reader,
                    buf: Vec::with_capacity(capacity),
                    pos: 0,
                }
            }

            #[allow(clippy::should_implement_trait)]
            pub fn next<T: std::str::FromStr>(&mut self) -> T
            where
                T::Err: std::fmt::Debug,
            {
                if self.buf.is_empty() {
                    self.read_next_line();
                }
                let mut start = None;
                loop {
                    if self.pos == self.buf.len() {
                        break;
                    }
                    match (self.buf[self.pos], start.is_some()) {
                        (b' ', true) | (b'\n', true) => break,
                        (_, true) | (b' ', false) => self.pos += 1,
                        (b'\n', false) => self.read_next_line(),
                        (_, false) => start = Some(self.pos),
                    }
                }
                let elem =
                    unsafe { std::str::from_utf8_unchecked(&self.buf[start.unwrap()..self.pos]) };
                elem.parse()
                    .unwrap_or_else(|_| panic!("{}", format!("failed parsing: {}", elem)))
            }

            fn read_next_line(&mut self) {
                self.pos = 0;
                self.buf.clear();
                if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
                    panic!("Reached EOF");
                }
            }
        }
        #[macro_export]
        macro_rules! bufwrite {
            ($($arg:tt)*) => {{
                use ::std::io::{BufWriter, Write};
                let mut out = BufWriter::new(::std::io::stdout().lock());
                ::std::write!(out, $($arg)*).unwrap();
            }};
        }

        #[macro_export]
        macro_rules! bufwriteln {
            ($($arg:tt)*) => {{
                use ::std::io::{BufWriter, Write};
                let mut out = BufWriter::new(::std::io::stdout().lock());
                ::std::writeln!(out, $($arg)*).unwrap();
            }};
        }

        pub struct StdinReader<R: std::io::BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: std::io::BufRead> StdinReader<R> {
            pub fn new(reader: R) -> Self {
                Self {
                    reader,
                    buf: Vec::new(),
                }
            }

            pub fn read_space<T: std::str::FromStr>(&mut self) -> T {
                self.read_until(b' ')
            }

            pub fn read_line<T: std::str::FromStr>(&mut self) -> T {
                self.read_until(b'\n')
            }

            fn read_until<T: std::str::FromStr>(&mut self, delim: u8) -> T {
                // self.bufに次のトークンをセットする
                loop {
                    self.buf.clear();
                    let len = self
                        .reader
                        .read_until(delim, &mut self.buf)
                        .expect("failed to reading bytes");
                    match len {
                        0 => panic!("early eof"),
                        1 if self.buf[0] == delim => (), //区切り文字だけなのでもう一度ループ
                        _ => {
                            // 最後の文字が区切り文字なら削除
                            if self.buf[len - 1] == delim {
                                self.buf.truncate(len - 1);
                            }
                            break;
                        }
                    }
                }
                let elem = unsafe { std::str::from_utf8_unchecked(&self.buf) };
                elem.parse()
                    .unwrap_or_else(|_| panic!("{}", format!("failed parsing: {}", elem)))
            }
        }
    }
    pub mod math {

        pub fn sieve_of_eratosthenes(end: usize) -> Vec<bool> {
            let mut is_prime = vec![true; end + 1];
            (is_prime[0], is_prime[1]) = (false, false);
            for i in 2..=((end as f64).sqrt() as usize) {
                if is_prime[i] {
                    for j in (i * 2..=end).step_by(i) {
                        is_prime[j] = false;
                    }
                }
            }
            is_prime
        }

        use super::num_trait::Zero;

        pub fn gcd<T>(a: T, b: T) -> T
        where
            T: std::marker::Copy,
            T: std::cmp::Eq,
            T: std::ops::Rem<Output = T>,
            T: Zero,
        {
            if b == T::zero() {
                a
            } else {
                gcd::<T>(b, a % b)
            }
        }

        pub fn lcm<T>(a: T, b: T) -> T
        where
            T: std::marker::Copy,
            T: std::ops::Mul<Output = T>,
            T: std::ops::Div<Output = T>,
            T: std::ops::Rem<Output = T>,
            T: std::cmp::Eq,
            T: Zero,
        {
            a / gcd::<T>(a, b) * b
        }
    }
    pub mod num_trait {
        pub trait Zero {
            fn zero() -> Self;
        }
        impl Zero for u8 {
            fn zero() -> Self {
                0
            }
        }
        impl Zero for u16 {
            fn zero() -> Self {
                0
            }
        }
        impl Zero for u32 {
            fn zero() -> Self {
                0
            }
        }
        impl Zero for u64 {
            fn zero() -> Self {
                0
            }
        }
        impl Zero for usize {
            fn zero() -> Self {
                0
            }
        }
    }
}
0