#![allow(non_snake_case, unused_imports)] use std::collections::{BinaryHeap, HashMap, HashSet}; use ac_library::{Additive, Min, Segtree}; use proconio::{input, marker::Usize1, marker::Chars}; use itertools::Itertools; #[allow(unused_macros)] macro_rules! d { ( $( $x:expr ),* $(,)? ) => { eprintln!( concat!( $( stringify!($x), "={:?} " ),* ), $( $x ),* ); }; } #[allow(dead_code)] fn yn(b: bool) -> &'static str { if b { "Yes" } else { "No" } } fn grid_overlap(a: (usize, usize), b: (usize, usize)) -> Option<(usize, usize)> { if a.0 <= b.0 && b.0 <= a.1 { Some((b.0, a.1.min(b.1))) } else if b.0 <= a.0 && a.0 <= b.1 { Some((a.0, b.1.min(a.1))) } else { None } } fn main() { input! { N: usize, A: [Usize1; N], Q: usize, } let freq = A.iter().counts(); let mut segt = Segtree::>::from(vec![0; N]); for (&k, v) in freq.into_iter() { d!(k, v); segt.set(k, v); } for _ in 0..Q { input! { L1: Usize1, R1: Usize1, L2: Usize1, R2: Usize1, } let ans = if let Some((l, r)) = grid_overlap((L1, R1), (L2, R2)) { let a = segt.prod(L1..=R1) >= 1; let b = segt.prod(L2..=R2) >= 1; let c = segt.prod(l..=r) >= 2; a && b && c } else { let a = segt.prod(L1..=R1) >= 1; let b = segt.prod(L2..=R2) >= 1; a && b }; println!("{}", yn(ans)); } }