题目:
代码:
import java.util.Scanner;
public class ReturnRubish {
static int[] x;
static int[] y;
public static void main(String[] args) {
int n;
Scanner scan = new Scanner(System.in);
n = scan.nextInt();
x = new int[n+1];
y = new int[n+1];
for(int i=1;i<=n;i++) {
x[i] = scan.nextInt();
y[i] = scan.nextInt();
}
rr(n);
}
public static void rr(int n) {
int[] score = {0,0,0,0,0};
for(int i=1;i<=n;i++) {
if(haveRubish(x[i]+1,y[i],n) && haveRubish(x[i]-1,y[i],n) && haveRubish(x[i],y[i]+1,n) && haveRubish(x[i],y[i]-1,n) ) {
int count = 0;
if(haveRubish(x[i]+1,y[i]+1,n))
count++;
if(haveRubish(x[i]+1,y[i]-1,n))
count++;
if(haveRubish(x[i]-1,y[i]+1,n))
count++;
if(haveRubish(x[i]-1,y[i]-1,n))
count++;
if(count == 0)
score[0]++;
else if(count == 1)
score[1]++;
else if(count ==2)
score[2]++;
else if(count ==3)
score[3]++;
else
score[4]++;
}
}
for(int j=0;j<5;j++)
System.out.println(score[j]);
}
public static boolean haveRubish(int xl,int yl,int n) {
for(int i=1;i<=n;i++)
if(xl == x[i])
if(yl == y[i])
return true;
return false;
}
}
主类名称改为Main