CF79B.Colorful Field
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Fox Ciel saw a large field while she was on a bus. The field was a n × m rectangle divided into 1 × 1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes.
After seeing the field carefully, Ciel found that the crop plants of each cell were planted in following procedure:
- Assume that the rows are numbered 1 to n from top to bottom and the columns are numbered 1 to m from left to right, and a cell in row i and column j is represented as (i, j).
- First, each field is either cultivated or waste. Crop plants will be planted in the cultivated cells in the order of (1, 1) → ... → (1, m) → (2, 1) → ... → (2, m) → ... → (n, 1) → ... → (n, m). Waste cells will be ignored.
- Crop plants (either carrots or kiwis or grapes) will be planted in each cell one after another cyclically. Carrots will be planted in the first cell, then kiwis in the second one, grapes in the third one, carrots in the forth one, kiwis in the fifth one, and so on.
The following figure will show you the example of this procedure. Here, a white square represents a cultivated cell, and a black square represents a waste cell.

Now she is wondering how to determine the crop plants in some certain cells.
小狐狸Ciel在乘公交车时看到了一大片田地。这片田地是一个 n×m 的矩形,被划分为若干个 1×1 的单元格。其中一些单元格是荒地,其余每个单元格中都种植着作物:胡萝卜、猕猴桃或葡萄中的一种。
经过仔细观察,Ciel 发现每个单元格中作物的种植遵循如下规则:
- 假设行从上到下编号为 1 到 n,列从左到右编号为 1 到 m,则第 i 行第 j 列的单元格记作 (i,j)。
- 首先,每个单元格要么被开垦(即用于种植),要么为荒地。作物将按如下顺序依次种在所有被开垦的单元格中:(1,1)→⋯→(1,m)→(2,1)→⋯→(2,m)→⋯→(n,1)→⋯→(n,m)。荒地单元格将被跳过。
- 作物(胡萝卜、猕猴桃或葡萄)将按循环顺序依次种入每个被开垦的单元格中:第一个被开垦的单元格种胡萝卜,第二个种猕猴桃,第三个种葡萄,第四个再种胡萝卜,第五个种猕猴桃,依此类推。
下图展示了该过程的一个示例。其中,白色方块代表被开垦的单元格,黑色方块代表荒地。

现在她想知道如何确定某些特定单元格中所种植的作物种类。
输入格式
In the first line there are four positive integers n, m, k, t (1 ≤ n ≤ 4·104, 1 ≤ m ≤ 4·104, 1 ≤ k ≤ 103, 1 ≤ t ≤ 103), each of which represents the height of the field, the width of the field, the number of waste cells and the number of queries that ask the kind of crop plants in a certain cell.
Following each k lines contains two integers a, b (1 ≤ a ≤ n, 1 ≤ b ≤ m), which denotes a cell (a, b) is waste. It is guaranteed that the same cell will not appear twice in this section.
Following each t lines contains two integers i, j (1 ≤ i ≤ n, 1 ≤ j ≤ m), which is a query that asks you the kind of crop plants of a cell (i, j).
第一行包含四个正整数 n、m、k、t(1≤n≤4⋅104,1≤m≤4⋅104,1≤k≤103,1≤t≤103),分别表示田地的高度、宽度、废地单元格的数量以及查询次数(每次查询询问某个单元格中种植的作物种类)。
接下来的 k 行,每行包含两个整数 a、b(1≤a≤n,1≤b≤m),表示单元格 (a,b) 为废地。保证该部分中同一单元格不会重复出现。
接下来的 t 行,每行包含两个整数 i、j(1≤i≤n,1≤j≤m),表示一次查询,要求你回答单元格 (i,j) 中种植的作物种类。
输出格式
For each query, if the cell is waste, print Waste. Otherwise, print the name of crop plants in the cell: either Carrots or Kiwis or Grapes.
对于每个查询,如果该单元格是废料,则输出 Waste。否则,输出该单元格中作物的名称:Carrots、Kiwis 或 Grapes。
输入输出样例
输入#1
4 5 5 6 4 3 1 3 3 3 2 5 3 2 1 3 1 4 2 3 2 4 1 1 1 1
输出#1
Waste Grapes Carrots Kiwis Carrots Carrots
说明/提示
The sample corresponds to the figure in the statement.
该样例对应题目描述中的图示。
输入解题思路,AI测评打分。不知道怎么写?