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 #112 (Div. 2)

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

  2. Codeforces Round #112 (Div. 2) D. Beard Graph

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

  3. Codeforces Round #633 (Div. 2)

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

  4. Codeforces Round #366 (Div. 2) 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 #354 (Div. 2) ABCD

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

  6. Codeforces Round #368 (Div. 2)

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

  7. cf之路,1,Codeforces Round #345 (Div. 2)

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

  8. Codeforces Round #279 (Div. 2) ABCDE

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

  9. Codeforces Round #262 (Div. 2) 1003

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

随机推荐

  1. RMAN多种备份脚本分享

    1.相关参数介绍: 命令行参数 描述 TARGET 为目标数据库定义的一个连接字符串,当连接到一个目标数据库时,该连续是SYSDBA连接.该用户拥有启动和关闭数据库的权利,必须属于OSDBA组,必须建 ...

  2. BZOJ 1615: [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机

    题目 1615: [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机 Time Limit: 5 Sec  Memory Limit: 64 MB Desc ...

  3. C# 调用迅雷 7 迅雷下载开放引擎

    最近有个项目需要用winform调用迅雷下载.上网百度后发现迅雷自带的com组件从迅雷5之后就废掉了,除了能添加任务,其余功能全不能用.后来又发现了迅雷下载开放引擎这么个东西 http://thund ...

  4. POJ 1330 Nearest Common Ancestors LCA题解

    Nearest Common Ancestors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19728   Accept ...

  5. 《数据通信与网络》笔记--虚电路网络:帧中继和ATM

    在之前的文章中已经介绍过虚电路交换,详细请参见:http://blog.csdn.net/todd911/article/details/9069447 这边介绍下使用虚电路交换的2中WAN技术:帧中 ...

  6. [Swust OJ 746]--点在线上(线段树解法及巧解)

    题目链接:http://acm.swust.edu.cn/problem/746/ Time limit(ms): 1000 Memory limit(kb): 65535   fate是一个数学大牛 ...

  7. DOM操作HTML文档

    概述 之前写过一些关于DOM方法的知识,理论方法的偏多,所以,这篇博客主要是实践方面的Demo,如果,大家觉得理论方面有所欠缺,大家可以看看这几篇博客:JavaScript总结(一.基本概念)和Jav ...

  8. 用Flask实现视频数据流传输

    Flask 是一个 Python 实现的 Web 开发微框架.这篇文章是一个讲述如何用它实现传送视频数据流的详细教程. 我敢肯定,现在你已经知道我在O’Reilly Media上发布了有关Flask的 ...

  9. Net FLow Template

    EK  Template : bool bfs(int src, int des){ memset(pre, -, sizeof(pre)); while(!que.empty()) que.pop( ...

  10. (Problem 17)Number letter counts

    If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + ...