#include <iostream> #include <bits/stdc++.h> #include <string> using namespace std; vector<Point> xy; int a=0,b=0,c=0,d=0,e=0; void isJudge(Point temp) { int sum=0; int sum1=0; for(int i=0; i<xy.size(); i++) { if(xy[i].x==temp.x) { if(xy[i].y==temp.y+1||xy[i].y==temp.y-1) sum++; } else if(xy[i].y==temp.y) { if(xy[i].x==temp.x+1||xy[i].x==temp.x-1) sum++; } else { if( abs(xy[i].x-temp.x)==1 && abs(xy[i].y-temp.y)==1 ) sum1++; } } if(sum==4) { switch (sum1) { case 0: a++; break; case 1: b++; break; case 2: c++; break; case 3: d++; break; case 4: e++; break; } } } int main() { int number; cin>>number; while(number--) { Point temp; cin>>temp.x>>temp.y; xy.push_back(temp); } for(int i=0; i<xy.size(); i++) { isJudge(xy[i]); } cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl<<e<<endl; }
原文:https://www.cnblogs.com/-Asurada-/p/14377255.html