Supercentral Point
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard 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).

解题思路:没什么说的。直接暴力搞了。

遍历每一个点,看是否符合要求。为了省时间,我们能够在输入的时候把x的上限,下限,和y的上限和下限先记录一下,在推断每一个点的时候会用到。

AC代码:

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define INF 0x7fffffffint x[205], y[205], a[2005][2005];int main()
{#ifdef sxkfreopen("in.txt","r",stdin);#endifint n, xx, yy, xxx, yyy, flag0, flag1, flag2, flag3;while(scanf("%d",&n)!=EOF){memset(a, 0, sizeof(a));xx = yy = -12345;xxx= yyy = 12345;for(int i=0; i<n; i++){scanf("%d%d", &x[i], &y[i]);x[i] += 1000;  y[i] += 1000;a[x[i]][y[i]] = 1;if(xx < x[i]) xx = x[i];       //纪录x。y范围if(xxx > x[i]) xxx = x[i];if(yy < y[i])  yy = y[i];if(yyy > y[i]) yyy = y[i];}int ans = 0;for(int i=0; i<n; i++){flag0 = flag1 = flag2 = flag3 = 0;for(int j=x[i]+1; j<=xx; j++){        //推断if( a[j][ y[i] ] ){flag0 = 1;break;}}  if(flag0){                        for(int j=xxx; j<x[i]; j++){if( a[j][ y[i] ] ){flag1 = 1;break;}}if(flag1){for(int j=y[i]+1; j<=yy; j++){if( a[x[i]][j] ){flag2 = 1;break;}}if(flag2){for(int j=yyy; j<y[i]; j++){if( a[x[i]][j] ){flag3 = 1;break;}}}}}if(flag3) ans ++;}printf("%d\n", ans);}return 0;
}

Codeforces Round #112 (Div. 2)---A. Supercentral Point相关推荐

  1. Codeforces Round #112 (Div. 2) E. Compatible Numbers sosdp

    传送门 文章目录 题意: 思路: 题意: 思路: 以下假设all=1<<22all=1<<22all=1<<22. 转化问题,对于每个aia_iai​我们都计算x= ...

  2. Educational Codeforces Round 112(Div.2) ABC题解

    D题好像可以做一做,挖个坑以后做好了来填(doge Educational Codeforces Round 112(Div.2) 题目列表 1.A 2.B 3.C 1.A 原题链接 题目大意 有三种 ...

  3. Educational Codeforces Round 112 (Rated for Div. 2)

    Educational Codeforces Round 112 (Rated for Div. 2) 题号 题目 知识点 A PizzaForces B Two Tables C Coin Rows ...

  4. Educational Codeforces Round 112 (Rated for Div. 2)(A-D)

    Educational Codeforces Round 112 (Rated for Div. 2) A 我写的挺烦的,其实判断一下奇偶数和有没有a>0就行 #include <bits ...

  5. Educational Codeforces Round 112 (Rated for Div. 2)-A. PizzaForces-题解

    目录 Educational Codeforces Round 112 (Rated for Div. 2)-A. PizzaForces Problem Description Input Outp ...

  6. Codeforces Round #604 (Div.2)

    Codeforces Round #604 (Div.2) 2019/12/5 22:35--2019/12/6 00:35 Codeforces Round #604 (Div.2) A. Beau ...

  7. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  8. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  9. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

最新文章

  1. .NET 4.5 基类库中的新增功能
  2. Windows内核函数的命名
  3. COJ 0650 绝世难题(一) 可爱的仙人掌
  4. Python学习:深入Python流程控制
  5. OpenGL散射照明
  6. 领域驱动设计-什么是领域驱动设计和怎么使用它
  7. P1516-青蛙的约会【扩欧,同余方程】
  8. 三星s7不能运行java_在调试模式下启动时Android应用程序崩溃
  9. 很久以前的C语言笔记
  10. asp.net mysql 读写分离_[ASP.net教程]SqlSugar ORM已经支持读写分离
  11. bash脚本比较运算符和if else和test命令
  12. Googel knowledge graph API
  13. 运营商iptv服务器,电信运营商IPTV业务发展趋势浅析
  14. parted如何将磁盘所有空间格式化_磁盘-使用parted格式化大容量数据盘
  15. 【转】WinRAR软件许可框
  16. jave获取视频时长
  17. uniapp省市区三级联动
  18. ext4文件系统错误处理机制
  19. (一)C++游戏开发-本地存储-介绍
  20. 零基础怎么学习平面设计

热门文章

  1. 【竞赛题解】第22次CCF计算机软件能力认证 B
  2. 前端的请求最大线程数是多少啊_面试官:创建多少个线程合适,我该怎么说?...
  3. [C++][线程安全]单例模式下双检查锁和线程
  4. Stack/Queue与Vector/List的联系
  5. 计算机网络【二】物理层基础知识
  6. 【C++ Primer | 15】面试问题
  7. java基础常问面试题,面试必问
  8. 交大c语言第一次作业答案,第一次作业答案(供参考)
  9. c 加密 java解密错误_java解密出错
  10. docker容器状态跟踪及疑惑