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.

题解:

判断一个点有没有被东西南北四个点包围 O(n^2)

s

 #include<stdio.h>
struct node{
int x;
int y;
}points[];
int main() {
int n ;
scanf("%d",&n);
for(int i = ; i < n; i++) {
scanf("%d %d",&points[i].x,&points[i].y);
}
int ans = ;
for(int i = ; i < n; i++) {
int a = ;
int b = ;
int c = ;
int d = ;
for(int j = ; j < n; j++) {
if(i == j) continue;
if(points[j].y == points[i].y && points[i].x < points[j].x) a = ; //right
else if(points[j].y == points[i].y && points[i].x > points[j].x) b = ; //left
else if(points[j].y > points[i].y && points[i].x == points[j].x) c = ; //up
else if(points[j].y < points[i].y && points[i].x == points[j].x) d = ; //down if((a + b + c + d )== ) {
ans++;
break;
} }
}
printf("%d\n",ans); return ;
}

最新文章

  1. [CodeWars][JS]实现大整数加法
  2. ORA-00942:table or view does not exist
  3. js运动框架之掉落的扑克牌(重心、弹起效果)
  4. UniversalAndroidImageLoader出现异常:ImageLoader: Unable to resolve host &quot;https&quot;: No address associated with host
  5. dede织梦后台如何修改?如何增加删除菜单?(
  6. Android中多个调用Activity的问题
  7. 手机上的频段GSM GPRS分别是什么
  8. nodejs 按行读取 readline
  9. Communication System
  10. window批处理-3.go
  11. Http Module 介绍(转载)
  12. Switch 语句
  13. ASM字节码框架学习之动态代理
  14. 解决Android模拟器卡慢的问题
  15. Codeforces Round #352 (Div. 2) (A-D)
  16. 【Concurrency-ScheduledExecutorService】
  17. Linux 第六天
  18. ccf--20140903--字符串匹配
  19. wamp下修改mysql root用户的登录密码方法
  20. 最短路径求解(Dijkstra)

热门文章

  1. java学习(4)——动手动脑
  2. 转 常见hash算法的原理
  3. 异或巧用:Single Number
  4. 【内存数据库】OracleTimesten连接DSN创建用户
  5. Evaluate Reverse Polish Notation --leetcode
  6. [IT学习]华为全连接大会2017
  7. ClassLoader如何加载class
  8. CASE UPDATE
  9. sabaki and leelazero
  10. JS数组array常用方法