結果
| 問題 |
No.2055 12x34...
|
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2022-08-30 16:46:32 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 2,000 ms |
| コード長 | 2,754 bytes |
| コンパイル時間 | 14,768 ms |
| コンパイル使用メモリ | 384,212 KB |
| 実行使用メモリ | 16,444 KB |
| 最終ジャッジ日時 | 2024-11-07 11:04:29 |
| 合計ジャッジ時間 | 18,567 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 41 |
ソースコード
use std::collections::HashMap;
//USE https://mirrorless-camera.info/column/14417.html
macro_rules! input {
($($r:tt)*) => {
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(std::io::stdin()));
let mut next = move |is_word: bool| -> String{
if is_word {
bytes
.by_ref()
.map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
} else {
bytes
.by_ref()
.map(|r|r.unwrap() as char)
.skip_while(|c| c == &'\n')
.take_while(|c| c != &'\n')
.collect()
}
};
input_inner!{next, $($r)*};
};
}
macro_rules! input_inner {
($next:expr) => {};
($next:expr, ) => {};
($next:expr, static $var:ident : $t:tt $($rest:tt)*) => {
$var = read_value!($next, $t);
input_inner!{$next $($rest)*}
};
($next:expr, mut $var:ident : $t:tt $($rest:tt)*) => {
let mut $var = read_value!($next, $t);
input_inner!{$next $($rest)*}
};
($next:expr, $var:ident : $t:tt $($rest:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($rest)*}
};
}
macro_rules! read_value {
($next:expr, ( $($t:tt),* )) => {
( $(read_value!($next, $t)),* )
};
($next:expr, [ $t:tt ; all ]) => { {
let mut str = $next(false);
str.split_whitespace().map(|it| it.parse::<$t>().unwrap()).collect::<Vec<_>>()
}
};
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len as usize).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, chars) => {
read_value!($next, String).chars().collect::<Vec<char>>()
};
($next:expr, lines) => {
{
let mut vec = Vec::new();
let mut str = $next(false);
while str != "" {
vec.push(str);
str = $next(false);
}
vec
}
};
($next:expr, line) => {
$next(false)
};
($next:expr, usize1) => {
read_value!($next, usize) - 1
};
($next:expr, $t:ty) => {
$next(true).parse::<$t>().expect("Parse error")
};
}
fn main() {
input! {
n : usize,
a : [usize; n]
}
let mut hm: HashMap<usize, usize> = HashMap::new();
let mut ans = 0;
for a in a{
*hm.entry(a).or_default() = (*hm.entry(a).or_default() + *hm.entry(a-1).or_default() +1)%998244353;
ans = (ans+hm[&(a-1)])%998244353;
}
println!("{}", ans);
}
H20