-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcolorful_field.java
68 lines (53 loc) · 1.1 KB
/
colorful_field.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.*;
import java.lang.*;
public class colorful_field{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int k=sc.nextInt();
int t=sc.nextInt();
int p=0;
int h=1;
int s[]=new int[k+1];
p=0;
for(int j=0;j<k;j++){
s[j]=(((sc.nextInt()-1)*m)+((sc.nextInt()-1)));
// System.out.println(s[j]);
}
s[k]=(n*m)+1;
Arrays.sort(s);
int c=0;
for(int l=0;l<t;l++){
p=(((sc.nextInt()-1)*m)+((sc.nextInt()-1)));
c=p;
h=1;
// System.out.println("#"+c);
for(int i=0;i<(k+1);i++){
if(p==s[i]){
System.out.println("Waste");
h=-1;
break;
}
}
if(h!=-1){
for(int y=0;y<(k+1);y++){
if(s[y]<p){
c=c-1;
h=1;
// System.out.println("*"+s[y]+" "+c+" ");
continue;
}
else break;
}}
if(h==1){
if(c%3==0)
System.out.println("Carrots");
else if(c%3==1)
System.out.println("Kiwis");
else
System.out.println("Grapes");
}
}
}
}