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

复制代码
 1 #include<stdio.h>
 2 struct node{
 3     int x;
 4     int y;
 5 }points[205];
 6 int main() {
 7     int n ;
 8     scanf("%d",&n);
 9         for(int i = 0; i < n; i++) {
10             scanf("%d %d",&points[i].x,&points[i].y);
11         }
12         int ans = 0;
13         for(int i = 0; i < n; i++) {
14             int a = 0;
15             int b = 0;
16             int c = 0;
17             int d = 0;
18             for(int  j = 0 ; j < n; j++) {
19                 if(i == j) continue;
20                 if(points[j].y == points[i].y && points[i].x < points[j].x) a = 1; //right
21                 else if(points[j].y == points[i].y && points[i].x > points[j].x) b = 1; //left
22                 else if(points[j].y > points[i].y && points[i].x == points[j].x) c = 1; //up
23                 else if(points[j].y < points[i].y && points[i].x == points[j].x) d = 1; //down
24                 
25                 if((a + b + c + d )== 4) {
26                     ans++;
27                     break;
28                 }
29                 
30             }
31         }
32         printf("%d\n",ans);
33     
34     
35     return 0;
36 }
复制代码

 

posted @   听说这是最长的名字了  阅读(231)  评论(0编辑  收藏  举报
编辑推荐:
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
阅读排行:
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(三):用.NET IoT库
· 【非技术】说说2024年我都干了些啥

阅读目录(Content)

此页目录为空

点击右上角即可分享
微信分享提示