結果

問題 No.116 門松列(1)
コンテスト
ユーザー dnikk
提出日時 2018-07-16 20:27:25
言語 Rust
(1.93.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 640 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 748 ms
コンパイル使用メモリ 202,052 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-11 06:25:25
合計ジャッジ時間 1,674 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unnecessary parentheses around closure body
  --> src/main.rs:20:25
   |
20 |             .filter(|x| (x[0] != x[1] && x[1] != x[2] && x[2] != x[0]))
   |                         ^                                            ^
   |
   = note: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default
help: remove these parentheses
   |
20 -             .filter(|x| (x[0] != x[1] && x[1] != x[2] && x[2] != x[0]))
20 +             .filter(|x| x[0] != x[1] && x[1] != x[2] && x[2] != x[0] )
   |

ソースコード

diff #
raw source code

fn main() {
    let mut _n = String::new();
    std::io::stdin().read_line(&mut _n).ok();

    let mut _n = _n.trim().parse::<usize>().unwrap();

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).ok();

    let a_vec = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect::<Vec<_>>();

    println!(
        "{}",
        a_vec
            .windows(3)
            .filter(|x| (x[0] != x[1] && x[1] != x[2] && x[2] != x[0]))
            .filter(|x| (x.iter().max().unwrap() == &x[1]) || (x.iter().min().unwrap() == &x[1]))
            .count()
    );
}
0