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 ...
 
随机推荐
- java大文件的分割和合并
			
原文:http://www.open-open.com/code/view/1441679313430 import java.io.File; import java.io.FileInputStr ...
 - volatile关键字解析&内存模型&并发编程中三概念
			
原文链接: http://www.cnblogs.com/dolphin0520/p/3920373.html volatile这个关键字可能很多朋友都听说过,或许也都用过.在Java5之前,它是一个 ...
 - mtk刷机错误汇总
			
MTK常见错误解读与解决方法: 1.刷机过了红条,到了紫色条卡住.(错误代码4008) 解决方法:这种情况出现的话,大家可以把电池拿下来,然后重新安装上,进入REC后选择关机.然后重新刷. 2.驱动安 ...
 - Linux程序设计(搭建开发环境--curses)
			
看官们.咱们今天要说的内容.是前面内容的一点小补充,详细的内容是:安装curses开发包.以搭建 开发环境.闲话休说,言归正转. 我们在前面说过搭建开发环境的内容,主要说了开发环境中的GCC和VIM, ...
 - IDEA-Maven的环境配置及使用
			
一.Maven的下载 IDEA的往期下载地址:https://www.jetbrains.com/ 1.点击进入 1.往期的下载地址:http://www.apache.org/ 操作步骤:我们点击进 ...
 - (原创)EasyUI中datagrid的行编辑模式中,找到特定的Editor,并为其添加事件
			
有时候在行编辑的时候,一个编辑框的值要根据其它编辑框的值进行变化,那么可以通过在开启编辑时,找到特定的Editor,为其添加事件 // 绑定事件, index为当前编辑行 var editors = ...
 - Bash Shell 解析路径获取文件名称和文件夹名
			
前言 还是今天再写一个自己主动化打包脚本.用到了从路径名中获取最后的文件名称.这里记录一下实现过程. 当然,最后我也会给出官方的做法.(ps:非常囧,实现完了才发现原来Bash Shell有现成的函数 ...
 - HDU 4897 Little Devil I 树链剖分+线段树
			
Little Devil I Problem Description There is an old country and the king fell in love with a devil. T ...
 - (转)SQL中使用or影响性能的解决办法
			
原文地址:https://www.cnblogs.com/xuxiaona/p/4962727.html 近期做了一个存储过程,执行时发现非常的慢,竟然需要6.7秒! 经排查,发现时间主要都耗在了其中 ...
 - C++ 函数部分(1)
			
1.编写一个求X的n次方的函数 .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas ...