Sample Input
5 3
dog
ate
homework
canary
died
My dog ate my homework.
Can you believe my dog died after eating my canary... AND MY HOMEWORK?
This excuse is so good that it contain 0 keywords.
6 5
superhighway
crazy
thermonuclear
bedroom
war
building
I am having a superhighway built in my bedroom.
I am actually crazy.
1234567890.....,,,,,0987654321?????!!!!!!
There was a thermonuclear war!
I ate my dog, my canary, and my homework ... note outdated keywords?
Sample Output
Excuse Set #1
Can you believe my dog died after eating my canary... AND MY HOMEWORK?
Excuse Set #2
I am having a superhighway built in my bedroom.
There was a thermonuclear war!
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class UVA409{
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int count = 1;
while(sc.hasNext())
{
int K = sc.nextInt();
int E = sc.nextInt();
System.out.println("Excuse Set #"+count);
sc.nextLine();
String K_box [] = new String[K];
String E_box [] = new String[E];
int print[] = new int[E];
int max = 0;
for(int i=0;i<K;i++)
K_box[i] = sc.nextLine();
for(int i=0;i<E;i++)
E_box[i] = sc.nextLine();
Set st = new HashSet();
for(int i =0;i<E;i++)
{
String temp="";
for(int e=0;e<E_box[i].length();e++)
{
if((E_box[i].charAt(e)>='a' && E_box[i].charAt(e)<='z') || (E_box[i].charAt(e)>='A' && E_box[i].charAt(e)<='Z'))
{
//排除非字情況
temp = temp + E_box[i].charAt(e);
}
else{
st.add(temp.toLowerCase());
temp="";
}
}
for(int k =0;k < K; k++)
{
//搜尋每一筆句子 含有多少個keyword
if(st.contains(K_box[k])){
print[i]++;
}
}
st.clear();
}
for(int p=0;p<E;p++)
{
if(max<print[p])
max=print[p];
}
for(int p=0;p<E;p++)
{
if(max==print[p])
System.out.println(E_box[p]);
}
System.out.println();
count++;
}
sc.close();
}
}