use std::io::*; fn permutation(n: usize, p: &mut Vec, used: &mut Vec, all: &mut Vec>) { if p.len() == n { all.push(p.to_vec()); return; } for i in 0..n { if !used[i] { p.push(i); used[i] = true; permutation(n, p, used, all); p.pop(); used[i] = false; } } } fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let b: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mut p: Vec = Vec::new(); let mut used = vec![false; n]; let mut all: Vec> = Vec::new(); let mut win = 0.0; permutation(n, &mut p, &mut used, &mut all); for i in 0..all.len() { let mut cnt = 0i32; for j in 0..n { if a[all[i][j]] > b[j] { cnt += 1; } if a[all[i][j]] < b[j] { cnt -= 1; } } if cnt > 0 { win += 1.0; } } println!("{:.10}", win / (all.len() as f64)); }