結果
問題 | No.133 カードゲーム |
ユーザー | maeda |
提出日時 | 2024-05-01 14:15:46 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,272 bytes |
コンパイル時間 | 21,055 ms |
コンパイル使用メモリ | 391,416 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 19:05:50 |
合計ジャッジ時間 | 18,457 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 1 ms
6,816 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
コンパイルメッセージ
warning: unused variable: `A` --> src/main.rs:23:21 | 23 | input!(N:usize, A:[usize;N], B:[usize;N]); | ^ help: if this is intentional, prefix it with an underscore: `_A` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `B` --> src/main.rs:23:34 | 23 | input!(N:usize, A:[usize;N], B:[usize;N]); | ^ help: if this is intentional, prefix it with an underscore: `_B` warning: constant `DX` is never used --> src/main.rs:18:7 | 18 | const DX: [i64; 4] = [0, 0, 1, -1]; | ^^ | = note: `#[warn(dead_code)]` on by default warning: constant `DY` is never used --> src/main.rs:19:7 | 19 | const DY: [i64; 4] = [1, -1, 0, 0]; | ^^
ソースコード
#![allow(non_snake_case)] #![allow(unused_imports)] use crate::lib::Permutation; use proconio::{ fastout, input, input_interactive, marker::{Chars, Isize1, Usize1}, }; use std::vec; #[allow(dead_code)] // const MOD: i64 = 1_000_000_007; // const MOD : i64 = 1_000_000_009; const MOD: i64 = 998_244_353; #[allow(dead_code)] const INF: i64 = 1_010_000_000_000_000_017; const DX: [i64; 4] = [0, 0, 1, -1]; const DY: [i64; 4] = [1, -1, 0, 0]; #[allow(non_snake_case)] fn main() { input!(N:usize, A:[usize;N], B:[usize;N]); let mut count_match = 0; let mut count_win_A = 0; let p = Permutation::new(&(0..N).collect()); for perm_A in p.clone() { for perm_B in p.clone() { count_match += 1; let mut win_A = 0; for i in 0..N { if perm_A[i] > perm_B[i] { win_A += 1; } } if win_A > N / 2 { count_win_A += 1; } } } println!("{}", count_win_A as f64 / count_match as f64) } pub mod lib { #[derive(Clone)] pub struct Permutation<T: Clone> { v: Vec<T>, l: Vec<usize>, not_start: bool, } impl<T: Clone> Permutation<T> { pub fn new(v: &Vec<T>) -> Permutation<T> { Permutation { l: vec![0; v.len()], v: v.clone(), not_start: true, } } } impl<T: Clone> Iterator for Permutation<T> { type Item = Vec<T>; fn next(&mut self) -> Option<Vec<T>> { // non-permutated vector if self.not_start { self.not_start = false; return Some(self.v.clone()); } for n in 0..self.v.len() { if self.l[n] < n { if (n + 1) % 2 == 1 { self.v.swap(0, n); self.l[n] += 1; } else { self.v.swap(self.l[n], n); self.l[n] += 1; } return Some(self.v.clone()); } else { self.l[n] = 0 } } return None; } } }