use std::{ collections::{BTreeSet, HashMap}, hash::Hash, }; fn main() { proconio::input! { n: usize, mut a: [u32; n], mut b: [u32; n], } let mut rng = Xorshift::new(); let mut win = 0; for _ in 0..10000000 { shuffle(&mut a, &mut rng); shuffle(&mut b, &mut rng); let mut w = 0; for i in 0..n { if a[i] > b[i] { w += 1; } } if w > n / 2 { win += 1 } } println!("{}", win as f64 / 10000000.); } fn shuffle(x: &mut [T], rng: &mut Xorshift) { for i in 0..x.len() { let j = rng.rand(x.len() as u64) as usize; x.swap(i, j); } } #[derive(Debug)] #[allow(dead_code)] pub struct Xorshift { seed: u64, } impl Xorshift { #[allow(dead_code)] pub fn new() -> Xorshift { Xorshift { seed: 0xf0fb588ca2196dac, } } #[allow(dead_code)] pub fn with_seed(seed: u64) -> Xorshift { Xorshift { seed: seed } } #[inline] #[allow(dead_code)] pub fn next(&mut self) -> u64 { self.seed = self.seed ^ (self.seed << 13); self.seed = self.seed ^ (self.seed >> 7); self.seed = self.seed ^ (self.seed << 17); self.seed } #[inline] #[allow(dead_code)] pub fn rand(&mut self, m: u64) -> u64 { self.next() % m } #[inline] #[allow(dead_code)] // 0.0 ~ 1.0 pub fn randf(&mut self) -> f64 { use std::mem; const UPPER_MASK: u64 = 0x3FF0000000000000; const LOWER_MASK: u64 = 0xFFFFFFFFFFFFF; let tmp = UPPER_MASK | (self.next() & LOWER_MASK); let result: f64 = unsafe { mem::transmute(tmp) }; result - 1.0 } }