use std::collections::*; struct RNG { s: usize } impl RNG { fn new(seed: usize) -> Self { RNG { s: seed, } } fn next(&mut self) -> usize { self.s = self.s * 12345 % 1000003; self.s } } struct Graph { map: BTreeMap>, } impl Graph { fn new() -> Self { Graph { map: BTreeMap::new(), } } fn insert_vertex(&mut self, v: usize, set: BTreeSet) { for u in set.iter() { self.map.get_mut(u).unwrap().insert(v); } assert!(self.map.insert(v, set).is_none()); } fn add_edge(&mut self, v: usize, u: usize) { assert!(v != u); assert!(self.map.get_mut(&v).unwrap().insert(u)); assert!(self.map.get_mut(&u).unwrap().insert(v)); } fn remove_vertex(&mut self, v: usize) -> BTreeSet { let set = self.map.remove(&v).unwrap(); for u in set.iter() { assert!(self.map.get_mut(u).unwrap().remove(&v)); } set } fn calc_mis(&mut self) -> BTreeSet { if self.map.is_empty() { return BTreeSet::new(); } if let Some((&v, _)) = self.map.iter().find(|p| p.1.len() <= 1) { let set = self.remove_vertex(v); let mut p = vec![]; for &u in set.iter() { p.push((u, self.remove_vertex(u))); } let mut res = self.calc_mis(); res.insert(v); for (u, set) in p.into_iter().rev() { self.insert_vertex(u, set); } self.insert_vertex(v, set); return res; } let v = *self.map.iter().max_by_key(|p| p.1.len()).unwrap().0; let set = self.remove_vertex(v); let mut ans = self.calc_mis(); let mut p = vec![]; for &u in set.iter() { p.push((u, self.remove_vertex(u))); } let mut q = self.calc_mis(); q.insert(v); if ans.len() < q.len() { ans = q; } for (u, set) in p.into_iter().rev() { self.insert_vertex(u, set); } self.insert_vertex(v, set); ans } } fn run() { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let mut rng = RNG::new(s.trim().parse().unwrap()); let n: usize = rng.next() % 120 + 2; let mut graph = Graph::new(); for i in 1..=n { graph.insert_vertex(i, BTreeSet::new()); } let p = rng.next(); for i in 1..=n { for j in (i + 1)..=n { let e = rng.next(); if e >= p { graph.add_edge(i, j); } } } let ans = graph.calc_mis(); let mut out = String::new(); out.push_str(&format!("{}\n", ans.len() + 1)); for a in ans { out.push_str(&format!("{} ", a)); } out.pop(); println!("{}", out); } fn main() { run(); }