Codeforces Round #112 (Div. 2)---A. Supercentral Point
2 seconds
256 megabytes
standard input
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.
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.
Print the only number — the number of supercentral points of the given set.
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
2
5
0 0
0 1
1 0
0 -1
-1 0
1
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的更多相关文章
- Codeforces Round #112 (Div. 2)
		Codeforces Round #112 (Div. 2) C. Another Problem on Strings 题意 给一个01字符串,求包含\(k\)个1的子串个数. 思路 统计字符1的位 ... 
- 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 ... 
- Codeforces Round #633 (Div. 2)
		Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3& ... 
- 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 ... 
- Codeforces Round #354 (Div. 2) ABCD
		Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ... 
- Codeforces Round #368 (Div. 2)
		直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ... 
- cf之路,1,Codeforces Round #345 (Div. 2)
		cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ... 
- Codeforces Round #279 (Div. 2) ABCDE
		Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ... 
- 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 ... 
随机推荐
- Ubuntu安装Adobe Reader
			到 这里依次选择最新版本的Adobe Reader,我选择目前最新的 9.5.5版本的,下载下来后,双击选择dep包,启动软件中心进行安装,中间会提示软件包欠佳,选择" ... 
- 基于visual Studio2013解决C语言竞赛题之0201温度转换
			题目 解决代码及点评 #include <stdio.h> #include <stdlib.h> void main() { float f; float c; float ... 
- BZOJ 1611: [Usaco2008 Feb]Meteor Shower流星雨
			1611: [Usaco2008 Feb]Meteor Shower流星雨 Description 去年偶们湖南遭受N年不遇到冰冻灾害,现在芙蓉哥哥则听说另一个骇人听闻的消息: 一场流星雨即将袭击整个 ... 
- JNI_Java Native Interface
			一.简介 Java Native Interface(JNI),java与c/c++交互的接口,下面是一个简单是示例. javah 可以生成native方法对应的头文件,javap 可以查看方法或者属 ... 
- <深入理解C指针>学习笔记和总结 第四章 指针和数组
			数组是一个什么玩意: 数组和指针我的理解,有同样之处也有不同之处.因有同样之处,因此一些资料上说,数组和指针本质是同样的.因有不同之处,因此也有一些资料上说,数组和指针是不一样的. 同样之处: 数组名 ... 
- HDU 4825 Xor Sum 字典树+位运算
			点击打开链接 Xor Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others) ... 
- 如何成为CSDN博客专家
			先看一下官方给出的要求: 申请CSDN博客专家应具备的条件: 1.原创IT类文章总数超过20篇,并且最近一个月内发布了新的原创IT类文章. 2.博客文章总的浏览量超过5万次以上. 3.文章内容的质量很 ... 
- Flash中用AS3做的游戏,导出apk安装到手机上滤镜效果出不来为什么?
			主要原因是,导出apk文件时渲染模式设置成了GPU.改掉就行了. 
- Windows(64位IIS)未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序
			在Windows 7(32位)用.Net开发的Excel导入数据表功能,测试后一切正常,站点发布挪到Windows Server 2008(64位)上就意外了,出现错误提示,运行程序,抛出异常:未在本 ... 
- Android自定义组合控件:UIScrollLayout(支持界面滑动及左右菜单滑动)
			一.前言: 我之前很早的时候,写过一篇<左右滑出菜单>的文章: http://blog.csdn.net/qingye_love/article/details/8776650 用的是对V ... 
