A - Supercentral Point CodeForces - 165A
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.
题解:
判断一个点有没有被东西南北四个点包围 O(n^2)
s
#include<stdio.h>
struct node{
int x;
int y;
}points[];
int main() {
int n ;
scanf("%d",&n);
for(int i = ; i < n; i++) {
scanf("%d %d",&points[i].x,&points[i].y);
}
int ans = ;
for(int i = ; i < n; i++) {
int a = ;
int b = ;
int c = ;
int d = ;
for(int j = ; j < n; j++) {
if(i == j) continue;
if(points[j].y == points[i].y && points[i].x < points[j].x) a = ; //right
else if(points[j].y == points[i].y && points[i].x > points[j].x) b = ; //left
else if(points[j].y > points[i].y && points[i].x == points[j].x) c = ; //up
else if(points[j].y < points[i].y && points[i].x == points[j].x) d = ; //down if((a + b + c + d )== ) {
ans++;
break;
} }
}
printf("%d\n",ans); return ;
}
A - Supercentral Point CodeForces - 165A的更多相关文章
- Codeforces Round #112 (Div. 2)---A. Supercentral Point
Supercentral Point time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces A. Supercentral Point 题解
版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/,未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- mybatis几种开发方式
mybatis是比较轻巧的半自动化的CRM框架,它有几种开发方式,现今张列于此: 一.注解方式:在接口方法上面写SQL语句,有点类似springdataJPA 的query sql 语句 范例 @se ...
- 【.Net 学习系列】-- EF Core实践(Code First)
一.开发环境: vs2015, .Net Framework 4.6.1 二.解决方案: 新建一个控制台应用程序 添加引用:Microsoft.EntityFrameworkCore.SqlServe ...
- sklearn特征工程总结
转自: http://www.cnblogs.com/jasonfreak/p/5448385.html https://www.zhihu.com/question/28641663/answer/ ...
- Scala入门到精通——第二十四节 高级类型 (三)
作者:摆摆少年梦 视频地址:http://blog.csdn.net/wsscy2004/article/details/38440247 本节主要内容 Type Specialization Man ...
- :>/dev/null 2>&1 的作用
shell中可能经常能看到:>/dev/null 2>&1 命令的结果可以通过%>的形式来定义输出 /dev/null 代表空设备文件 > 代表重定向到哪里,例如:ec ...
- fixedBox固定div漂浮代码 支持ie6以上大部分浏览器
fixedBox固定div漂浮代码 支持ie6以上大部分浏览器 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E ...
- Android 使用图片异步载入框架Universal Image Loader的问题
使用的Jar包 问题: optionsm = new DisplayImageOptions.Builder() .displayer(new RoundedBitmap ...
- 【ios系列】-数据储存
第一:plist属性列表 适用对象:仅仅是Foundation框架自带的一些类比如:NString\NSarry\NSDictionary\NSset\NSnumber\NSdata 使用: 1:调用 ...
- Codeforces 794F. Leha and security system 线段树
F. Leha and security system Bankopolis, the city you already know, finally got a new bank opened! ...
- HDU 2512 一卡通大冒险(dp)
一卡通大冒险 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...