module Program let read() = stdin.ReadLine().Split() |> Array.map int let XL(x, _, _, _) = x let YU(_, x, _, _) = x let XR(_, _, x, _) = x let YD(_, _, _, x) = x let width, height = 2500, 2500 let N, xLB, xRB = let t = read() t.[0], t.[1] + 500, t.[2] + 500 let info = Array.init N (fun _ -> let t = read() |> Array.map ((+) 500) (t.[0], t.[1], t.[2], t.[3])) let front = Array.zeroCreate (width + 5) for t in info do let YD = YD t for idx in (XL t)..(XR t) do front.[idx] <- max front.[idx] YD for t in info do let YD = YD t front.[(max xLB (XL t))..(min xRB (XR t))] |> Array.exists ((=) YD) |> function | true -> 1 | _ -> 0 |> printfn "%i"