Obstacles for a Llama
문제
A llama wants to travel through the Andean Plateau. It has a map of the plateau in the form of a grid of square cells. The rows of the map are numbered from to from top to bottom, and the columns are numbered from to from left to right. The cell of the map in row and column () is denoted by .
The llama has studied the climate of the plateau and discovered that all cells in each row of the map have the same temperatureand all cells in each column of the map have the same humidity. The llama has given you two integer arrays and of length and respectively. Here () indicates the temperature of the cells in row , and () indicates the humidity of the cells in column .
The llama has also studied the flora of the plateau and noticed that a cell is free of vegetation if and only if its temperature is greater than its humidity, formally .
The llama can travel across the plateau only by following valid paths. A valid path is a sequence of distinct cells that satisfy the following conditions:
- Each pair of consecutive cells in the path shares a common side.
- All cells in the path are free of vegetation.
Your task is to answer questions. For each question, you are given four integers: , and . You must determine whether there exists a valid path such that:
- The path starts at cell and ends at cell .
- All cells in the path lie within columns to , inclusive.
It is guaranteed that both and are free of vegetation.