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

时间:2023-01-15 11:09:39
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 0x7fffffff int x[205], y[205], a[2005][2005]; int main()
{
#ifdef sxk
freopen("in.txt","r",stdin);
#endif
int 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 &num;112 &lpar;Div&period; 2&rpar;

    Codeforces Round #112 (Div. 2) C. Another Problem on Strings 题意 给一个01字符串,求包含\(k\)个1的子串个数. 思路 统计字符1的位 ...

  2. Codeforces Round &num;112 &lpar;Div&period; 2&rpar; D&period; Beard Graph

    地址:http://codeforces.com/problemset/problem/165/D 题目: D. Beard Graph time limit per test 4 seconds m ...

  3. Codeforces Round &num;633 &lpar;Div&period; 2&rpar;

    Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3& ...

  4. Codeforces Round &num;366 &lpar;Div&period; 2&rpar; ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  5. Codeforces Round &num;354 &lpar;Div&period; 2&rpar; ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  6. Codeforces Round &num;368 &lpar;Div&period; 2&rpar;

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  7. cf之路,1,Codeforces Round &num;345 &lpar;Div&period; 2&rpar;

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  8. Codeforces Round &num;279 &lpar;Div&period; 2&rpar; ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  9. Codeforces Round &num;262 &lpar;Div&period; 2&rpar; 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

随机推荐

  1. Hadoop基础学习框架

    我们主要使用Hadoop的2个部分:分布式文件存储系统(HDFS)和MapReduce计算模型. 关于这2个部分,可以参考一下Google的论文:The Google File System 和 Ma ...

  2. Freemark基本语法知识(转)

    FreeMarker的模板文件并不比HTML页面复杂多少,FreeMarker模板文件主要由如下4个部分组成: 1,文本:直接输出的部分 2,注释:<#-- ... -->格式部分,不会输 ...

  3. Enum 枚举小结 java &ast;&ast;&ast;&ast; 最爱那水货

    import java.util.HashMap; import java.util.Map; /** * 收单行 大写首字母 和对应的编码<br/> * * ABC 农业银行<br ...

  4. SQL简繁转换函数

    declare @jall nvarchar(4000),@fall nvarchar(4000) select @jall=N'啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翱袄傲奥懊 ...

  5. Object-c-数组的使用

    一.数组: 1.数组初始化: a.NSArray *array = [[NSArray alloc] init]; b.NSArray *array = [[NSArray array]; 2.初始化 ...

  6. ios网络&colon;应用一个请求的7个步骤

    Splitting big tasks into small tasks is often one of the best ways to solve a problem. Thus, in the ...

  7. flask入门篇

    flask,Flask是一个使用 Python 编写的轻量级 Web 应用框架.其 WSGI 工具箱采用 Werkzeug ,模板引擎则使用 Jinja2 . Flask简单易学,属于轻量级的,学起来 ...

  8. 使用chcache 缓存

    在项目里碰到了表单提交和ajax访问后台取到的request对象不是同一个对象,所以不能够资源共享,问了大神决定配置一个缓存来处理这个问题. 引用jar :ehcache-core-2.5.2.jar ...

  9. WPF Blend 脑洞大开的问题:如何用Blend得到或画出一个凹槽、曲面。

    原文:WPF Blend 脑洞大开的问题:如何用Blend得到或画出一个凹槽.曲面. 目标图: 步骤一(放置一个矩形,填充蓝色): 步骤二(复制该矩形,并调整边角,填充粉红色): 第三部:让图形部分重 ...

  10. iOS 百度地图截屏

    关于百度地图截屏的问题,发现不能用常用的方法进行载屏,常用的截屏方法所得到的图片地图瓦片底图会显示空白,网上给出的答案是这样的 :因为百度地图不是用UIKit实现的,所以得不到截图! 不过通过Open ...