結果

問題 No.805 UMG
ユーザー iwotiwot
提出日時 2020-06-08 21:35:35
言語 Rust
(1.77.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 13,768 ms
コンパイル使用メモリ 379,656 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 11:08:37
合計ジャッジ時間 15,413 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 9 ms
5,376 KB
testcase_24 AC 10 ms
5,376 KB
testcase_25 AC 10 ms
5,376 KB
testcase_26 AC 9 ms
5,376 KB
testcase_27 AC 10 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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)

ソースコード

diff #

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);
}
0