結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2024-05-01 14:15:46 |
言語 | Rust (1.83.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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | WA * 19 |
コンパイルメッセージ
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 vectorif 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;}}}