CCF--201912-2 回收站选址
#include<iostream>
using namespace std;
struct node{
int x;
int y;
int flag = 0;
int score = 0;
}node;
int main(){
int n;
cin >> n;
struct node arr[n];
int scores[5] = {0,0,0,0,0};
for(int i = 0; i < n; i++){
cin >> arr[i].x >> arr[i].y;
}
int x0, y0;
//check
for(int i = 0; i < n; i++){
x0 = arr[i].x;
y0 = arr[i].y;
for(int j = 0; j < n; j++){
if(x0 == arr[j].x && (y0+1) == arr[j].y){
arr[i].flag ++;
}
if(x0 == arr[j].x && (y0-1) == arr[j].y){
arr[i].flag ++;
}
if((x0+1) == arr[j].x && y0 == arr[j].y){
arr[i].flag ++;
}
if((x0-1) == arr[j].x && y0 == arr[j].y){
arr[i].flag ++;
}
if((x0+1) == arr[j].x && (y0+1) == arr[j].y){
arr[i].score ++;
}
if((x0-1) == arr[j].x && (y0-1) == arr[j].y){
arr[i].score ++;
}
if((x0+1) == arr[j].x && (y0-1) == arr[j].y){
arr[i].score ++;
}
if((x0-1) == arr[j].x && (y0+1) == arr[j].y){
arr[i].score ++;
}
}
if(arr[i].flag == 4){
scores[arr[i].score] ++;
}
}
for(int i = 0; i < 5; i++){
cout << scores[i] << endl;
}
}
害,打几个循环就能出来的事,我当初却只有0分,真是太drama了