mod p1468 { use std::collections::BTreeSet; fn gather(v: Vec) -> BTreeSet { v.into_iter().fold(BTreeSet::new(), |mut acc, s| { acc.insert(s); acc }) } pub fn solve(begin: Vec, after: Vec) -> String { let begin_set = gather(begin); let after_set = gather(after); let sub = &begin_set ^ &after_set; if sub.is_empty() { begin_set } else { sub }.iter().collect::>()[0].to_owned() } } struct Input { num: usize, begin: Vec, after: Vec, } impl Input { fn readline(len: usize) -> Vec { use std::io::{self, BufRead}; let stdin = io::stdin(); let lines = stdin.lock().lines().map(|l| l.unwrap().to_string()); lines.take(len).collect() } fn accept(len: usize) -> Self { let lines = Self::readline(len); let num = lines[0].parse::().unwrap(); let begin = lines[1].split(" ").map(|s| s.to_string()).collect::>(); let after = lines[2].split(" ").map(|s| s.to_string()).collect::>(); Self { num, begin, after, } } } fn main() { let args = Input::accept(3); let result = p1468::solve(args.begin, args.after); println!("{}", result); }