This commit is contained in:
2025-12-28 21:05:06 +08:00
parent 5d09b15326
commit bdaedc135e
46 changed files with 485 additions and 38 deletions
+31 -38
View File
@@ -1,48 +1,41 @@
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
if (!in.hasNext()) {
System.out.print("no");
in.close();
return;
}
int n = Integer.parseInt(in.next());
if (n <= 0) {
System.out.print("no");
in.close();
return;
}
Map<String, Integer> cnt = new HashMap<>();
Map<String, Integer> first = new HashMap<>();
String best = null;
int bestCount = 0;
int bestIdx = Integer.MAX_VALUE;
int idx = 0;
while (idx < n && in.hasNext()) {
String raw = in.next();
String norm = new BigInteger(raw).toString();
int c = cnt.getOrDefault(norm, 0) + 1;
cnt.put(norm, c);
if (!first.containsKey(norm))
first.put(norm, idx);
int fi = first.get(norm);
if (best == null || c > bestCount || (c == bestCount && fi < bestIdx)) {
best = norm;
bestCount = c;
bestIdx = fi;
int n = in.nextInt();
int[] mention = new int[101];
boolean[][] by = new boolean[101][101];
for (int i = 0; i < n; i++) {
int sender = in.nextInt();
int k = in.nextInt();
for (int j = 0; j < k; j++) {
int id = in.nextInt();
if (id >= 0 && id <= 100) {
mention[id]++;
if (sender >= 0 && sender <= 100) by[id][sender] = true;
}
}
idx++;
}
if (best == null)
System.out.print("no");
else
System.out.print(best);
int bestId = 0;
int bestCount = -1;
for (int id = 0; id <= 100; id++) {
if (mention[id] > bestCount) {
bestCount = mention[id];
bestId = id;
}
}
System.out.println(bestId);
StringBuilder sb = new StringBuilder();
boolean first = true;
for (int s = 0; s <= 100; s++) {
if (by[bestId][s]) {
if (!first) sb.append(' ');
sb.append(s);
first = false;
}
}
System.out.println(sb.toString());
in.close();
}
}