use std::collections::HashMap; use std::io::{stdout, Write}; struct State { h: [[bool; 14]; 13], v: [[bool; 13]; 14], dp: [[usize; 14 * 14]; 14 * 14], sum_s: u32, paths: HashMap<(usize, usize, usize, usize), usize>, highway_count: u32, collaborator_count: u32, money: u64, } impl State { fn new() -> Self { let mut dp = [[0; 14 * 14]; 14 * 14]; for start_i in 0..14 { for start_j in 0..14 { for goal_i in 0..14 { for goal_j in 0..14 { let mut value = 0; if start_i > goal_i { value += start_i - goal_i; } else { value += goal_i - start_i; } if start_j > goal_j { value += start_j - goal_j; } else { value += goal_j - start_j; } dp[start_i * 14 + start_j][goal_i * 14 + goal_j] = 1000 * value; } } } } let mut paths = HashMap::new(); for _ in 0..3000 { let abcd: Vec = read_vec(); let (a, b, c, d) = (abcd[0] - 1, abcd[1] - 1, abcd[2] - 1, abcd[3] - 1); paths.insert((a, b, c, d), dp[a * 14 + b][c * 14 + d]); } Self { h: [[false; 14]; 13], v: [[false; 13]; 14], dp, sum_s: 0, paths, highway_count: 0, collaborator_count: 1, money: 1_000_000, } } fn solve(&mut self, t: usize) { let uv: Vec = read_vec(); println!("2"); stdout().flush().unwrap(); } } fn main() { let mut state = State::new(); for t in 0..400 { state.solve(t); } } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }