package com.njupt.acm;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class POJ_1598 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int counter = 1;
while(scanner.hasNext()){
int k = scanner.nextInt();
int e = scanner.nextInt();
String keys[] = new String[k];
String excuses[] = new String[e];
Map map = new HashMap();
int i, j;
for (i = 0; i < k; ++i) {
keys[i] = scanner.next().toLowerCase();
}
String no_use = scanner.nextLine();
for (i = 0; i < e; ++i) {
excuses[i] = scanner.nextLine().trim();
}
for (i = 0; i < e; ++i) {
int count = 0;
String temp = excuses[i].toLowerCase();
for (j = 0; j < k; ++j) {
while (temp.contains(keys[j])) {
temp = temp.replace(keys[j], "");
count++;
}
}
map.put(excuses[i], count);
}
int max = 0;
for (i = 0; i < map.size(); ++i) {
if (((Integer) map.get(excuses[i])) > max) {
max = ((Integer) map.get(excuses[i]));
}
}
System.out.println("Excuse Set #" + (counter++));
for (i = 0; i < map.size(); ++i) {
if (((Integer) map.get(excuses[i])) == max) {
System.out.println(excuses[i]);
}
}
System.out.println();
}
}
}
POJ 1958 没有AC的版本
最新推荐文章于 2020-02-03 19:47:42 发布