-
Notifications
You must be signed in to change notification settings - Fork 0
/
LittleElephantAndStrings.java
48 lines (41 loc) · 1.32 KB
/
LittleElephantAndStrings.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
package problems.codechef;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by arpit on 10/1/17.
*/
public class LittleElephantAndStrings {
static String favouriteLuckyStrings[]=new String[50];
static BufferedReader br;
public static void main(String[] args) throws IOException {
br=new BufferedReader(new InputStreamReader(System.in));
int k,n;
String s[]=br.readLine().split("\\s");
k=Integer.parseInt(s[0]);
n=Integer.parseInt(s[1]);
for (int i = 0; i < k; i++) {
favouriteLuckyStrings[i]=br.readLine();
}
solve(favouriteLuckyStrings,k,n);
}
private static void solve(String[] favouriteLuckyStrings, int k, int n) throws IOException {
for (int i = 0; i < n; i++) {
String s=br.readLine();
boolean flag=false;
if (s.length()<47)
for (int j = 0; j < k; j++) {
if (s.contains(favouriteLuckyStrings[j])){
System.out.println("Good");
flag=true;
break;
}
}
else{
System.out.println("Good");
flag=true;
}
if (!flag) System.out.println("Bad");
}
}
}