import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String one[] = in.nextLine().split(" ");
String two[] = in.nextLine().split(" ");
int Ln = Integer.valueOf(one[0]);
int Rn = Integer.valueOf(two[0]);
String L[] = new String[Ln];
// int R[] = new int[Rn];
TreeSet<Integer> R = new TreeSet<>();
for (int i = 0; i < Ln; i++) {
L[i] = one[i + 1];
}
for (int i = 0; i < Rn; i++) {
R.add(Integer.valueOf(two[i+1]));
}
/*****分割线*****/
int num = 0;
StringBuilder sb = new StringBuilder();
for (int i:R) {
int count = 0;
TreeMap<Integer, String> map = new TreeMap<>();
for (int j = 0; j < Ln; j++) {
if (L[j].contains(String.valueOf(i))) {
count++;
map.put(j, L[j]);
}
}
if (!map.isEmpty()) {
num+=2;
sb.append(i).append(" ");
sb.append(count).append(" ");
for(int m:map.keySet()){
num+=2;
sb.append(m).append(" ");
sb.append(map.get(m)).append(" ");
}
}
}
StringBuilder sb2 = new StringBuilder();
sb2.append(num).append(" ").append(sb.toString());
System.out.println(sb2.toString());
}
}
OJ---数据分类处理
最新推荐文章于 2025-04-10 16:10:39 发布