use proconio::input_interactive; fn main() { input_interactive! { x:usize, y:usize, } for n in 3.. { for v in 0..1 << n { let mut ops = [[0; 2]; 2]; let mut possible = [[false; 2]; 2]; for p in 0..1 << 4 { for i in 0..2 { for j in 0..2 { if p & (1 << (2 * i + j)) != 0 { ops[i][j] = 1; } else { ops[i][j] = 0; } } } let t = calc(&ops, v, n); possible[t][ops[x][y]] = true; } if (possible[0][0] ^ possible[0][1]) && (possible[1][0] ^ possible[1][1]) { solve(&possible, n, v); return; } } } } fn solve(possible: &[[bool; 2]; 2], n: usize, v: usize) { println!("{}", n); for i in 0..n { print!("{} ", (v >> i) & 1); } println!(); input_interactive! { t:usize, } if possible[t][0] { println!("0"); } else { println!("1"); } } fn calc(ops: &[[usize; 2]; 2], v: usize, n: usize) -> usize { let mut res = ops[v & 1][(v >> 1) & 1]; for i in 2..n { res = ops[res][(v >> i) & 1]; } res }