CCF201912-2

CCF201912-2

#include
#include
#include

 using namespace std;
 
 typedef struct{
     
 	long long x,y;
 	int index;
 }plot;
 
 bool cmp_x(plot p1,plot p2){
     
 	return p1.x<p2.x;
 }
 
 
 int findx(vector<plot> t,long long x){
     
 	int len = t.size();
 	for(int i=0;i<len;i++){
     
 		if(t[i].x==x){
     
 			return i;
 		}
 	}
 	return -1;
 }
 
 bool process(vector<plot> t,vector<plot> tx,long long x,long long y){
     
 	int start = findx(tx,x);
 	int len = tx.size();
 	if(start==-1){
     
 		return false;
 	}
 	while(start<len&&tx[start].x==x){
     
 		int index = tx[start].index;
 		if(t[index].y==y){
     
 			return true;
 		}
 		start++;
 	}
 	return false;
 }
 void func(){
     
 	int n;
 	cin>>n;
 	vector<plot> tmp;
 	for(int i=0;i<n;i++){
     
 		long long x,y;
 		cin>>x>>y;
 		plot p;
 		p.x = x;
 		p.y = y;
 		p.index = i;
 		tmp.push_back(p);
 	}
 	vector<int> ans(5,0);
 	vector<plot> tmpx = tmp;
 	sort(tmpx.begin(),tmpx.end(),cmp_x);
 	for(int i=0;i<n;i++){
     
 		long long x = tmp[i].x;
 		long long y = tmp[i].y;
 		bool x1 = process(tmp,tmpx,x+1,y);
 		bool x2 = process(tmp,tmpx,x-1,y);
 		bool x3 = process(tmp,tmpx,x,y+1);
 		bool x4 = process(tmp,tmpx,x,y-1);
 		if(x1&&x2&&x3&&x4){
     
 			int num = 0;
 			if(process(tmp,tmpx,x+1,y+1))
 				num++;
 			if(process(tmp,tmpx,x+1,y-1))
 				num++;
 			if(process(tmp,tmpx,x-1,y+1))
 				num++;
 			if(process(tmp,tmpx,x-1,y-1))
 				num++;
			ans[num]++;	
 		}
 	}
 	for(int i=0;i<5;i++){
     
 		cout<<ans[i]<<endl;
 	}
 	
 }
 int main(){
     
 	func();
 	return 0;
 }

你可能感兴趣的:(CCF)