fn main() { let n = read(); let mut p = (1..=n).collect::>(); p.sort_by(|a, b| { println!("? {} {}", *a, *b); let res = read(); use std::cmp::Ordering::*; if res == 1 { Less } else { Greater } }); println!("!"); println!("{}", p.len()); use util::*; println!("{}", p.iter().join(" ")); } fn read() -> usize { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().parse().unwrap() } mod util { pub trait Join { fn join(self, sep: &str) -> String; } impl Join for I where I: Iterator, T: std::fmt::Display, { fn join(self, sep: &str) -> String { let mut s = String::new(); use std::fmt::*; for (i, v) in self.enumerate() { if i > 0 { write!(&mut s, "{}", sep).ok(); } write!(&mut s, "{}", v).ok(); } s } } }