結果
| 問題 |
No.805 UMG
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-08 21:35:35 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 892 bytes |
| コンパイル時間 | 12,655 ms |
| コンパイル使用メモリ | 392,232 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 14:03:22 |
| 合計ジャッジ時間 | 13,854 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:22:9 | 22 | read!(n:usize); | ^ | help: `n` is captured in macro and introduced a unused variable --> src/main.rs:3:9 | 3 | let $x:$type = $v[$idx].clone().parse().unwrap(); | ^^ ... 22 | read!(n:usize); | -------------- in this macro invocation = note: `#[warn(unused_variables)]` on by default = note: this warning originates in the macro `read` (in Nightly builds, run with -Z macro-backtrace for more info)
ソースコード
macro_rules! read {
($x:ident, $v:expr, $idx:expr, $type:ty) => {
let $x:$type = $v[$idx].clone().parse().unwrap();
};
( $($x:ident:$t:ty),* ) => {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
let input:Vec<String> = s.trim()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect();
let mut idx:i64 = -1;
$(
idx += 1;
read!($x, input, idx as usize, $t);
)*
};
}
fn main() {
read!(n:usize);
read!(s:String);
let cs = s.chars().collect::<Vec<char>>();
let ans = (0..cs.len()-2).fold(0, |acc1, ui| {
if cs[ui] == 'U' {
acc1 + (ui..cs.len()-1).fold(0, |acc2, mi| {
if cs[mi] == 'M' && mi+mi-ui < cs.len() && cs[mi+mi-ui] == 'G' {
acc2 + 1
} else {
acc2
}
})
} else {
acc1
}
});
println!("{}", ans);
}