题目还没公布,先贴代码

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    public void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[][] point = new int[n][2];
        int[] count = new int[5];
        sc.nextLine();
        for(int i = 0; i < n; i++) {
            String[] s = sc.nextLine().split(" ");
            point[i][0] = Integer.valueOf(s[0]);
            point[i][1] = Integer.valueOf(s[1]);
        }

        sort(point, n);

        for(int i = 0; i < n; i++) {
            int c = 0;
            int f = 0;
            for(int j = i-1; j >= 0 && point[j][0] >= point[i][0]-1; j--) {
                if(point[i][0] == point[j][0] && point[i][1]-1 == point[j][1]) {
                    f++;
                }
                if(point[i][0] == point[j][0] && point[i][1]+1 == point[j][1]) {
                    f++;
                }
                if(point[i][0]-1 == point[j][0] && point[i][1] == point[j][1]) {
                    f++;
                }
                if(point[i][0]-1 == point[j][0] && point[i][1]-1 == point[j][1]) {
                    c++;
                }
                if(point[i][0]-1 == point[j][0] && point[i][1]+1 == point[j][1]) {
                    c++;
                }
            }
            for(int j = i+1; j < n && point[j][0] <= point[i][0]+1; j++) {
                if(point[i][0] == point[j][0] && point[i][1]-1 == point[j][1]) {
                    f++;
                }
                if(point[i][0] == point[j][0] && point[i][1]+1 == point[j][1]) {
                    f++;
                }
                if(point[i][0]+1 == point[j][0] && point[i][1] == point[j][1]) {
                    f++;
                }
                if(point[i][0]+1 == point[j][0] && point[i][1]-1 == point[j][1]) {
                    c++;
                }
                if(point[i][0]+1 == point[j][0] && point[i][1]+1 == point[j][1]) {
                    c++;
                }
            }
            if(c >= 0 && f==4) {
                count[c]++;
            }
        }
        for(int k = 0; k < 5; k++) {
            System.out.println(count[k]);
        }


    }

    private void sort(int[][] point, int n) {
        int[] temp = new int[2];
        for(int i = 0; i < n-1; i++) {
            for(int j = i + 1; j < n; j++) {
                if(point[i][0] > point[j][0]) {
                    temp = point[i];
                    point[i] = point[j];
                    point[j] = temp;
                }else if(point[i][0] == point[j][0] && point[i][1] > point[j][1]) {
                    temp = point[i];
                    point[i] = point[j];
                    point[j] = temp;
                }
            }
        }

    }

}
12-20 14:12