Obstacles for a Llama
시간 제한2초메모리 제한2048 MB
행별 온도와 열별 습도가 주어지고 T[i] > H[j]일 때만 지나갈 수 있으며, 열 L부터 R까지만 써서 (0,S)와 (0,D)가 연결되는지 묻는 질의에 답한다.
문제
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.
제한
- for each such that .
- for each such that .
- Both cells and are free of vegetation.
예제
이 문제는 공개된 예제가 없습니다.