結果

問題 No.1053 ゲーミング棒
ユーザー tabataba
提出日時 2024-08-05 17:10:47
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 686 bytes
コンパイル時間 13,059 ms
コンパイル使用メモリ 395,420 KB
実行使用メモリ 14,016 KB
最終ジャッジ日時 2024-08-05 17:11:14
合計ジャッジ時間 18,202 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,140 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 0 ms
6,940 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused imports: `HashMap`, `HashSet`
 --> src/main.rs:1:24
  |
1 | use std::collections::{HashMap, HashSet};
  |                        ^^^^^^^  ^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

ソースコード

diff #

use std::collections::{HashMap, HashSet};

fn main() {
    proconio::input! {
        n: usize,
        mut a: [u32; n],
    }
    // remove duplicates
    loop {
        let a_len = a.len();
        a = a
            .iter()
            .copied()
            .enumerate()
            .filter(|(i, _)| *i == a.len() - 1 || a[*i] != a[*i + 1])
            .map(|x| x.1)
            .collect();
        if a.len() == a_len {
            break;
        }
    }
    eprintln!("{a:?}");
    match a.iter().map(|x| a.iter().filter(|&y| y == x).count()).max() {
        Some(1) => println!("0"),
        Some(2) if a[0] == a[a.len() - 1] => println!("1"),
        _ => println!("-1"),
    }
}
0