use std::collections::*; use std::io::Write; type Map = BTreeMap; type Set = BTreeSet; type Deque = VecDeque; // bool が帰ってくる // N=500 // Q=5000 // N log_2 N // 厳しめ // 個数を特定するのに2N程度使ってしまう // ここからマージしていく? // 足りるか微妙なラインだが fn main() { use util::*; let n = read().parse::().unwrap(); let mut cnt = 0; let mut query = |b: Vec| -> bool { cnt += 1; assert!(cnt <= 5000); use util::*; println!("? {} {}", b.len(), b.iter().join(" ")); read() == "Yes" }; let mut a = vec![]; let mut rem = n; for i in 1..n { let mut b = vec![i]; while b.len() <= rem && query(b.clone()) { b.push(i); } b.pop(); rem -= b.len(); a.push(b); } if rem > 0 { a.push(vec![n; rem]); } while a.len() > 1 { a.sort_by_key(|a| !a.len()); let x = a.pop().unwrap(); let y = a.pop().unwrap(); let mut z = x.clone(); let mut po = 0; for y in y { while po < z.len() { let mut t = z.clone(); t.insert(po, y); if query(t) { break; } po += 1; } z.insert(po, y); po += 1; } a.push(z); } println!("! {}", a[0].iter().join(" ")); } fn read() -> String { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); String::from(s.trim()) } 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 } } }