165A
A. Supercentral Point
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1,?y1),?(x2,?y2),?...,?(xn,?yn). Let's define neighbors for some fixed point from the given set (x,?y):
point (x',?y') is (x,?y)'s right neighbor, if x'?>?x and y'?=?y
point (x',?y') is (x,?y)'s left neighbor, if x'?<?x and y'?=?y
point (x',?y') is (x,?y)'s lower neighbor, if x'?=?x and y'?<?y
point (x',?y') is (x,?y)'s upper neighbor, if x'?=?x and y'?>?y
We'll consider point (x,?y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.
Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.
Input
The first input line contains the only integer n (1?≤?n?≤?200) — the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|,?|y|?≤?1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.
Output
Print the only number — the number of supercentral points of the given set.
Sample test(s)
input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
output
2
input
5
0 0
0 1
1 0
0 -1
-1 0
output
1
Note
In the first sample the supercentral points are only points (1,?1) and (1,?2).
In the second sample there is one supercental point — point (0,?0).

1 #include<stdio.h> 2 #include<math.h> 3 #include<string.h> 4 #include<stdlib.h> 5 struct ln{ 6 int x; 7 int y; 8 }p[205]; 9 int xcmp(const void*a,const void*b) 10 { 11 if((*(struct ln*)a).x==(*(struct ln*)b).x) 12 return (*(struct ln*)a).y>(*(struct ln*)b).y?1:-1; 13 else 14 return (*(struct ln*)a).x>(*(struct ln*)b).x?1:-1; 15 } 16 int ycmp(const void*a,const void*b) 17 { 18 if((*(struct ln*)a).y==(*(struct ln*)b).y) 19 return (*(struct ln*)a).x>(*(struct ln*)b).x?1:-1; 20 else 21 return (*(struct ln*)a).y>(*(struct ln*)b).y?1:-1; 22 } 23 int main() 24 { 25 //freopen("in.txt","r",stdin); 26 int n,k,z=0,i; 27 int q[205],w[205],e[205],r[205]; 28 int ymin=0,ymax=0,xmin=0,xmax=0; 29 int t=0,h=0; 30 scanf("%d",&n); 31 for(i=0;i<n;i++) 32 { 33 scanf("%d %d",&p[i].x,&p[i].y); 34 if(p[i].y<ymin) 35 ymin=p[i].y; 36 if(p[i].y>ymax) 37 ymax=p[i].y; 38 39 if(p[i].x<xmin) 40 xmin=p[i].x; 41 if(p[i].x>xmax) 42 xmax=p[i].x; 43 } 44 qsort(p,n,sizeof(struct ln),ycmp); 45 for(i=0;i<n;i++) 46 { 47 if(p[i].y!=ymin&&p[i].y!=ymax) 48 { 49 if(p[i-1].y==p[i].y&&p[i].y==p[i+1].y) 50 { 51 q[t]=p[i].x; 52 w[t]=p[i].y; 53 t++; 54 } 55 } 56 } 57 qsort(p,n,sizeof(struct ln),xcmp); 58 for(i=0;i<n;i++) 59 { 60 if(p[i].x!=xmin&&p[i].x!=xmax) 61 { 62 if(p[i-1].x==p[i].x&&p[i].x==p[i+1].x) 63 { 64 e[h]=p[i].x; 65 r[h]=p[i].y; 66 h++; 67 } 68 } 69 } 70 for(i=0;i<t;i++) 71 { 72 for(int j=0;j<h;j++) 73 { 74 if(q[i]==e[j]&&w[i]==r[j]) 75 z++; 76 } 77 } 78 printf("%d ",z); 79 return 0; 80 }