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. 51cto培训课程

    课程: 云计算: OpenStack | 虚拟化 | 云平台 | Office 365 | 云服务 | Docker | 其他 大数据: Spark | Hadoop | Storm | Hive | ...

  2. 2015暑假acm短训小结

    时间很快,短训已经结束,短短20天,心里有一些思绪想要记下. 收获: 从最近发的随笔中可以看出,做得最多的是搜索——Dfs,Bfs.对于搜索,如何描述状态,如何压缩状态,如何决定下一个结点,是否可以剪 ...

  3. Python重写C语言程序100例--Part9

    ''' [程序71] 题目:编写input()和output()函数输入,输出5个学生的数据记录. 1.程序分析: 2.程序源码: 使用list来模拟结构(不使用class) stu = [strin ...

  4. POJ 2486 Apple Tree ( 树型DP )

    #include <iostream> #include <cstring> #include <deque> using namespace std; #defi ...

  5. jQuery遍历table

    1. $("table").find("tr").each(function(){ $(this).find("td").each(func ...

  6. sqlserver 分页查询总结

    sqlserver2008不支持关键字limit ,所以它的分页sql查询语句将不能用mysql的方式进行,幸好sqlserver2008提供了top,rownumber等关键字,这样就能通过这几个关 ...

  7. [Swust OJ 643]--行列式的计算(上三角行列式变换)

    题目链接:http://acm.swust.edu.cn/problem/643/ Time limit(ms): 1000 Memory limit(kb): 65535   Description ...

  8. 10994 - Simple Addition(规律)

    Problem E Simple Addition Input: Standard Input Output: Standard Output Let’s define a simple recurs ...

  9. Android保存之SharedPreferences

    Android中一共有四种存储方式: SharedPreferences 为其中的一种,具体还是看代码: package com.wyl.preferencetest; import android. ...

  10. Python-zip压缩-解压

    #打包成zip文件 import zipfile f = zipfile.ZipFile('archive.zip','w',zipfile.ZIP_DEFLATED) f.write('file_t ...