結果

問題 No.133 カードゲーム
コンテスト
ユーザー reicalgrst
提出日時 2026-10-06 15:04:41
言語 Rust
(1.99.0 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 5,000 ms
+ 825µs
コード長 802 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,243 ms
コンパイル使用メモリ 185,432 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-10-06 15:04:55
合計ジャッジ時間 6,521 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use itertools::{Itertools, iproduct};
use proconio::input;

// https://maguro.dev/blog/debug-macro/
#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),* $(,)*) => {
        #[cfg(debug_assertions)]
        eprintln!(concat!($("| ", stringify!($a), " = {:?} "),*, "|"), $(&$a),*);
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
        b: [usize; n]
    }

    let mut all = 0;
    let mut win = 0;
    for (u, v) in iproduct!(a.iter().permutations(n), b.iter().permutations(n)) {
        let mut cnt = 0;
        for i in 0..n {
            if u[i] > v[i] {
                cnt += 1;
            }
        }

        win += (n / 2 < cnt) as usize;
        all += 1;
    }

    debug!(all, win);
    let res = (win as f64) / (all as f64);
    println!("{res}");
}
0