Codeforces Round #112 (Div. 2)---A. Supercentral Point

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;
}



本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/399109.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

php imap配置,怎么为PHP编译imap扩展?

为PHP编译imap扩展的方法&#xff1a;首先安装“imap-open2007e”&#xff1b;然后下载源代码&#xff1b;接着准备好系统的“imap-open”环境&#xff1b;最后进入“./ext/extension/imap/”文件夹下执行“make”命令即可。怎么为PHP编译imap扩展&#xff1f;最近为项目增加了…

加载指定路径下所有文件

工作中经常遇到加载某个文件夹下的所有文件&#xff0c;然后对文件遍历&#xff0c;今天写代码时遇到一个好的类ArrayDeque&#xff0c;整理一下&#xff0c;做一下笔记 下面写了一个测试类 package com.hpzx.test;import java.io.File; import java.util.ArrayDeque; import j…

每日站立会议个人博客二

事件昨天干了什么优化了商品详细信息界面的多个图片显示方式今天要做什么对商品搜索结果页面进行深度优化&#xff0c;增加搜索筛选功能遇到的问题多图片显示实现过程中&#xff0c;图片的排列方式出现了问题。转载于:https://www.cnblogs.com/mqlblog/p/8063718.html

vmware安装minimal centos报错/etc/rc5.d/s99local : line

2019独角兽企业重金招聘Python工程师标准>>> 有人用vmware安装minimal centos报错/etc/rc5.d/s99local : line:25 : eject : command not found 。我们看下完整报错内容&#xff1a; Installing VMware Tools, please wait...mount: special device /dev/hda does n…

php print div,JavaScrip实现PHP print_r的数功能(三种方法)

方法一function print_r(theObj) {var retStr ;if (typeof theObj object) {retStr ;for (var p in theObj) {if (typeof theObj[p] object) {retStr [p] > typeof(theObj) ;retStr print_r(theObj[p]) ;} else {retStr [p] > theObj[p] ;}}retStr ;}re…

Android源代码下载方法具体解释

作者&#xff1a;张星 相信非常多下载过内核的人都对这个非常熟悉 git clone git://android.git.kernel.org/kernel/common.git kernel 可是这是在曾经&#xff0c;如今假设这么运行的话&#xff0c;会显演示样例如以下内容 Initialized empty Git repository in /home/star/w…

一些概念

1. 分布式锁&#xff1a;考虑利用redis的原子性特性&#xff0c;先确定redis中是否已处理过某个请求。如果没有&#xff0c;就创建&#xff0c;然后执行。执行完&#xff0c;清除redis里面的标记。因为redis是共享的&#xff0c;所以这种方式可以过滤掉重复请求引起的问题。 2.…

linux function

#!/bin/bashfunction sayHello() { #这里的{ 和它前面的)之间可以没有空格echo "Hello $1" }sayHello Neeky 转载于:https://www.cnblogs.com/JiangLe/p/5100271.html

后缀树(Suffix Trie)子串匹配结构

Suffix Trie 又称后缀Trie或后缀树。它与Trie树的最大不同在于&#xff0c;后缀Trie的字符串集合是由指定字符串的后缀子串构成的。比如、完整字符串"minimize"的后缀子串组成的集合S分…

java中的线程和进程,Java | 线程和进程,创建线程

一、线程与进程线程定义进程中执行的一个代码段&#xff0c;来完成不同的任务组成&#xff1a;线程ID&#xff0c;当前指令指针(PC)&#xff0c;寄存器集合(存储一部分正在执行线程的处理器状态的值)和堆栈进程定义执行的一段程序&#xff0c;一旦程序被载入到内存中准备执行就…

Maven的pom报错的解决方法

如果在MyEclipse里面导入项目,导入不了,如下图 接下来可以点击Import Maven Projects里的Action那一行Resolve Later. 点击Do Not Execute(add to pom)就可以正常导入了转载于:https://www.cnblogs.com/JimmySeraph/p/8068299.html

django零开始

2019独角兽企业重金招聘Python工程师标准>>> 安装。。。后查看 import django django.VERSION #输出版本号&#xff0c;目前自己是py2.7.9和django1.8 1&#xff0c;新建一个django-project django-admin.py startproject project-name 一个project一般为一个项目 …

php 大批量的删除图片,PHP批量删除记录同时删除图片文件

非常感谢老师的回答&#xff1a;全选&#xff0c;反选。已完成。可是PHP批量删除记录同时删除文件。代码不知怎么弄。请您给我代码好吗&#xff1f;if (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue …

关于Python3.6下登陆接口的尝试

编者按&#xff1a;README:此代码为用户登陆界面&#xff0c;添加了寻求帮助选项。1.学习了基本数据类型&#xff0c;string, int&#xff0c;以及while循环&#xff0c;continue, break, if, elif, else条件语句&#xff0c;“x".format&#xff08;x&#xff09;变量替代…

堆溢出的DWORD Shoot核心原理-口语化

1、双向链表上有a、b、c一共3个连续的堆块&#xff0c;a、b、c三者之间的实际物理地址可能相差很大&#xff0c;但是绝对不会三者之间无其他字节&#xff0c;如果无其他字节&#xff0c;那表示他们三个可以合并成一个物理连接起来的大块&#xff0c;堆管理系统很快会让他们三者…

* 类描写叙述:字符串工具类 类名称:String_U

/******************************************* 类描写叙述&#xff1a;字符串工具类 类名称&#xff1a;String_U* ******************************************/public class String_U {private String_U() {}/*** 检查手机号是否合法* * param phoneNum* return boolean tru…

git 撤销 merging

当我们在合代码的时候经常会遇到一些问题&#xff0c;这时候分支就处于merging状态&#xff0c;这时候可以用下面的命令撤销$ git reset --hard HEAD (or sha_1) 不知道有没有更好的办法&#xff0c;希望大家能给出自己的办法 转载于:https://www.cnblogs.com/WangHaiMing/p/80…

php 命令安装tp5,tp5.1框架的下载与安装方法步骤(图文)

大家可以都知道啊&#xff0c;tp框架5.1之前的版本都是可以在thinkphp的官网进行下载压缩包来安装框架的&#xff0c;那么在从tp5.1开始啊&#xff0c;就取消了下载压缩包安装的方法&#xff0c;那么我们如何进行下载呢&#xff1f;tp5.1的手册中开始就有提到tp5.1框架有两种安…

[连载]《C#通讯(串口和网络)框架的设计与实现》- 13.中英文版本切换设计

目 录 第十三章 中英文版本切换设计... 2 13.1 不用自带的资源文件的理由... 2 13.2 配置文件... 2 13.3 语言管理类... 3 13.4 应用管理类... 12 13.5 小结... 12 第十三章 中英文版本切换设计 13.1 不用自带的资源文件…

【JavaScript】apply和call的区别在哪?

我在一开始看到javascript的函数apply和call时,非常的模糊,看也看不懂,最近在网上看到一些文章对apply方法和call的一些示例,总算是看的有点眉目了,在这里我做如下笔记,希望和大家分享.. 如有什么不对的或者说法不明确的地方希望读者多多提一些意见,以便共同提高.. 主要我是要解…