自定义一个Point用来存放点,然后将point存放在map中,每次都进行更新。每一帧都新建一个map,若上一帧中存在该点,则将该点对应的值+1,并存放在map中,判断是否为新的最大。若上一帧不存在该点,则存放入map中,value为1 import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
HashMap points = new HashMap();
for(int i = 0; i < n; i ++){
int m = sc.nextInt();
int res = 0;
for(int j = 0; j < m; j ++){
int p = sc.nextInt();
HashMap tempPoints = new HashMap();
for (int k = 0; k < p; k ++){
int x = sc.nextInt();
int y = sc.nextInt();
Point temp = new Point(x,y);
Integer num = points.get(temp);
if (num == null){
num = new Integer(1);
} else{
num += 1;
}
res = num > res ? num : res;
tempPoints.put(temp,num);
}
points.clear();
points = tempPoints;
}
System.out.print(res);
}
}
}
class Point{
int x;
int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public Point() {
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Point point = (Point) o;
return x == point.x &&
y == point.y;
}
@Override
public int hashCode() {
return Objects.hash(x, y);
}
}