900AFind Extra One
来源:互联网 发布:凤凰新闻软件下载 编辑:程序博客网 时间:2024/05/22 08:14
You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis.
The first line contains a single positive integer n (2 ≤ n ≤ 105).
The following n lines contain coordinates of the points. The i-th of these lines contains two single integers xi and yi (|xi|, |yi| ≤ 109, xi ≠ 0). No two points coincide.
Print "Yes" if there is such a point, "No" — otherwise.
You can print every letter in any case (upper or lower).
31 1-1 -12 -1
Yes
41 12 2-1 1-2 2
No
31 22 14 60
Yes
In the first example the second point can be removed.
In the second example there is no suitable for the condition point.
In the third example any point can be removed.
题意:在坐标系中,给你n个点的坐标,让你去掉一个点,如果这些点能够在y轴同一侧,就输出Yes,否则就输出No。
题解:主要判断横坐标>0和小于0的个数。如果两个个数
#include<bits/stdc++.h>using namespace std;int main(){ int n,cnt1,cnt2,x,y; while(cin>>n) { cnt1=cnt2=0; for(int i=0; i<n; i++) { cin>>x>>y; if(x>0) cnt1++; else cnt2++; } if(cnt1>1&&cnt2>1) puts("No"); else puts("Yes"); } return 0;}
都大于1,肯定不行的,其余情况就输出是可以的。
- 900AFind Extra One
- codeforces 900A. Find Extra One
- codeforces 900C. Remove Extra One
- Codeforces 900C-Remove Extra One
- Codeforces 900C Remove Extra One
- codeforces 900C. Remove Extra One
- A. Find Extra One
- 【Codeforces 900C】Remove Extra One(BIT思维)
- codeforces Remove Extra One(思维)
- CF#450 C.Remove Extra One
- CF900C:Remove Extra One(思维)
- Extra
- Add One Bool Field to Player Extra Field
- CF 900.C Remove Extra One 单调栈+BIT
- Codeforces Round #450 (Div. 2) C. Remove Extra One 暴力
- Remove Extra One Codeforces Round #450 (Div. 2)(线段树)
- Extra Krunch
- day3 extra
- Oracle数据库常用where比较
- etcd 启用 https
- C# 占位符的使用
- 百度上传插件 WebUploader初始使用
- Spring MVC rest 09 火推
- 900AFind Extra One
- 【LeetCode】648.Replace Words(Medium)解题报告
- scala数据结构之Set和Map
- MVC AOP 10火推
- 最新高清IT职业技能图谱:机器学习、架构师、大数据、前端、运维,全套免费下载
- 图像分割中各个指标的计算方法
- 斐波那契数列的三种解法及时间复杂度
- java--设计模式
- 应用TF-Slim快速实现迁移学习