#![allow(non_snake_case)] #[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut tokens = $s.split_whitespace(); input_inner! { tokens, $($r)* } }; ($($r:tt)*) => { let s = { use std::io::Read; let mut res = String::new(); ::std::io::stdin().read_to_string(&mut res).unwrap(); res }; let mut tokens = s.split_whitespace(); input_inner! { tokens, $($r)* } }; } #[allow(unused_macros)] macro_rules! input_inner { ($tokens:expr) => {}; ($tokens:expr,) => {}; ($tokens:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($tokens, $t); input_inner! { $tokens $($r)* } }; } #[allow(unused_macros)] macro_rules! read_value { ($tokens:expr, ( $($t:tt),* )) => { ( $(read_value!($tokens, $t)),* ) }; ($tokens:expr, [ $t:tt; $len:expr ]) => { (0..$len).map(|_| read_value!($tokens, $t)).collect::>() }; ($tokens:expr, chars) => { read_value!($tokens, String).chars().collect::>() }; ($tokens:expr, usize1) => { read_value!($tokens, usize) - 1 }; ($tokens:expr, $t:ty) => { $tokens.next().unwrap().parse::<$t>().expect("parse error") }; } use std::cmp; fn main() { const W: i64 = 1280; const H: i64 = 1680; input! { N: usize, L: i64, R: i64, E: [(i64,i64,i64,i64); N], } // 0-based let L = L-1; let R = R-1; let E: Vec<_> = E.iter().map(|(l,u,r,d)| (l-1,u-1,r-1,d-1)).collect(); const EMPTY: i64 = -1; const BEAM: i64 = -2; let mut screen = vec![vec![EMPTY; W as usize]; (H+1) as usize]; for x in L..R+1 { screen[H as usize][x as usize] = BEAM; } for (i,&(l,u,r,d)) in E.iter().enumerate() { let l = cmp::max(l, 0); let u = cmp::max(u, 0); let r = cmp::min(r, W-1); let d = cmp::min(d, H-1); for y in u..d+1 { for x in l..r+1 { screen[y as usize][x as usize] = i as i64; }} } let mut ans = vec![0; N]; for y in (0..H).rev() { for x in 0..W { let cur = screen[y as usize][x as usize]; let below = screen[(y+1) as usize][x as usize]; if cur == EMPTY && below == BEAM { screen[y as usize][x as usize] = BEAM; } else if below == BEAM { ans[cur as usize] = 1; } }} for e in ans { println!("{}", e); } }