結果

問題 No.188 HAPPY DAY
ユーザー SarievoSarievo
提出日時 2023-05-23 16:31:27
言語 Rust
(1.77.0 + proconio)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 5,284 bytes
コンパイル時間 13,720 ms
コンパイル使用メモリ 378,572 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 03:36:36
合計ジャッジ時間 14,470 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::collections::HashSet`
 --> src/main.rs:1:5
  |
1 | use std::collections::HashSet;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused macro definition: `map`
 --> src/main.rs:5:14
  |
5 | macro_rules! map { () => { ::std::collections::HashMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ const CAP: usize = $crate:...
  |              ^^^
  |
  = note: `#[warn(unused_macros)]` on by default

warning: unused macro definition: `set`
 --> src/main.rs:6:14
  |
6 | macro_rules! set { () => { ::std::collections::HashSet::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem...
  |              ^^^

warning: unused macro definition: `btmap`
 --> src/main.rs:7:14
  |
7 | macro_rules! btmap { () => { ::std::collections::BTreeMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ let mut map = ::std::co...
  |              ^^^^^

warning: unused macro definition: `btset`
 --> src/main.rs:8:14
  |
8 | macro_rules! btset { () => { ::std::collections::BTreeSet::new() }; ($($elem: expr),+ $(,)?) => {{ let mut set = ::std::collections::BTre...
  |              ^^^^^

warning: unused macro definition: `deque`
 --> src/main.rs:9:14
  |
9 | macro_rules! deque { () => { ::std::collections::VecDeque::new() }; ($elem: expr; $n: expr) => {{ let mut deque = ::std::collections::Vec...
  |              ^^^^^

warning: unused macro definition: `bheap`
  --> src/main.rs:10:14
   |
10 | macro_rules! bheap { () => { ::std::collections::BinaryHeap::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($(...
   |              ^^^^^

warning: unused macro definition: `cvec`
  --> src/main.rs:19:14
   |
19 | macro_rules! cvec { ($($tokens: tt)+) => { $crate::c![$($tokens)+].collect::<::std::vec::Vec<_>>() }; }
   |              ^^^^

warning: unused macro definition: `cmap`
  --> src/main.rs:20:14
   |
20 | macro_rules! cmap { ($key:expr => $value:expr; $(

ソースコード

diff #

use std::collections::HashSet;
// Copyright (c) 2023 Sarievo
// https://github.com/GrayJack/sugars/blob/dev/LICENSE
#[macro_export] macro_rules! count { (@subst $($x: tt)*) => (()); ($($rest: expr),*) => (<[()]>::len(&[$($crate::count!(@subst $rest)),*])); }
macro_rules! map { () => { ::std::collections::HashMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($key),*); let mut map = ::std::collections::HashMap::with_capacity(CAP); $(let _ = map.insert($key, $value);)+map }}; }
macro_rules! set { () => { ::std::collections::HashSet::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem),*); let mut set = ::std::collections::HashSet::with_capacity(CAP); $(let _ = set.insert($elem);)+set }}; }
macro_rules! btmap { () => { ::std::collections::BTreeMap::new() }; ($($key: expr => $value: expr),+ $(,)?) => {{ let mut map = ::std::collections::BTreeMap::new(); $(let _ = map.insert($key, $value);)+map }}; }
macro_rules! btset { () => { ::std::collections::BTreeSet::new() }; ($($elem: expr),+ $(,)?) => {{ let mut set = ::std::collections::BTreeSet::new(); $(set.insert($elem);)+set }}; }
macro_rules! deque { () => { ::std::collections::VecDeque::new() }; ($elem: expr; $n: expr) => {{ let mut deque = ::std::collections::VecDeque::new(); deque.resize_with($n, || $elem);deque }}; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem),*); let mut deque = ::std::collections::VecDeque::with_capacity(CAP); $(deque.push_back($elem);)+deque }}; }
macro_rules! bheap { () => { ::std::collections::BinaryHeap::new() }; ($($elem: expr),+ $(,)?) => {{ const CAP: usize = $crate::count!($($elem),*); let mut bheap = ::std::collections::BinaryHeap::with_capacity(CAP); $(bheap.push($elem);)+bheap }} }
#[macro_export] macro_rules! c {
    ($e:expr; $i:pat in $iter:expr) => { $iter.map(|$i| $e) };
    ($e:expr; $i:pat in $iter:expr, if $cond:expr) => {{ $iter.filter(|$i| $cond).map(|$i| $e) }};
    ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr) => {{ $iter1.flat_map(|$i1| $iter2.map(move |$i2| $e)) }};
    ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr, if $cond:expr) => {{ $iter1.flat_map(|$i1| $iter2.filter_map(move |$i2| if $cond { Some($e) } else { None })) }};
    ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr, $i3:pat in $iter3:expr) => {{ $iter1.flat_map(|$i1| $iter2.flat_map(move |$i2| $iter3.map(move |$i3| $e))) }};
    ($e:expr; $i1:pat in $iter1:expr, $i2:pat in $iter2:expr, $i3:pat in $iter3:expr, if $cond:expr) => {{ $iter1.flat_map(|$i1| { $iter2.flat_map(move |$i2| { $iter3.filter_map(move |$i3| if $cond { Some($e) } else { None }) }) }) }};
}
macro_rules! cvec { ($($tokens: tt)+) => { $crate::c![$($tokens)+].collect::<::std::vec::Vec<_>>() }; }
macro_rules! cmap { ($key:expr => $value:expr; $($tokens: tt)+) => {{ $crate::c![ ($key, $value); $($tokens)+ ].collect::<::std::collections::HashMap<_, _>>() }}; }
macro_rules! cset { ($($tokens: tt)+) => {{ $crate::c![$($tokens)+].collect::<::std::collections::HashSet<_>>() }}; }
macro_rules! cbtmap { ($key:expr => $value:expr; $($tokens: tt)+) => {{ $crate::c![ ($key, $value); $($tokens)+ ].collect::<::std::collections::BTreeMap<_, _>>() }}; }
macro_rules! cbtset { ($($tokens: tt)+) => {{ $crate::c![$($tokens)+].collect::<::std::collections::BTreeSet<_>>() }}; }
macro_rules! cdeque { ($($tokens: tt)+) => {{ use std::collections::VecDeque; $crate::c![$($tokens)+].collect::<::std::collections::VecDeque<_>>() }}; }
macro_rules! cbheap { ($($tokens: tt)+) => {{ use std::collections::BinaryHeap; $crate::c![$($tokens)+].collect::<::std::collections::BinaryHeap<_>>() }}; }

const DX: [i32; 8] = [0, 1, 0, -1, 1, 1, -1, -1];
const DY: [i32; 8] = [1, 0, -1, 0, 1, -1, -1, 1];

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let mut cnt = 0;
    let max_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    for i in 1..=12 {
        for j in 1..=max_days[i - 1] {
            let d1 = j % 10;
            let d2 = j / 10;
            if d1 + d2 == i {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self { Self(r, std::io::BufWriter::new(w)) }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.0.by_ref().bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }.parse().ok().expect("Parse error.")
    }
    pub fn chars(&mut self) -> Vec<char> { self.read::<String>().chars().collect() }
    pub fn usize0(&mut self) -> usize { self.read::<usize>() - 1 }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
}
0