CSU: B
来源:互联网 发布:lol优化电脑提高fps 编辑:程序博客网 时间:2024/05/17 20:33
description
The International Collegiate Soccer1 Competition (ICSC) is famous for its well-kept rectangular stadiums. The grass playing fields in ICSC stadiums are always 100 meters long, and 75 meters wide. The grass is mowed every week with special lawn mowers, always using the same strategy: first, they make a series of passes along the length of the field, and then they do the same along the width of the field. All passes are straight lines, parallel to the sides of the field.
The ICSC has hired a new lawn-mower, Guido. Guido is very chaotic, and instead of covering the field incrementally, he likes to choose random starting positions for each of his passes. But he is afraid of not doing a good job and being red by the ICSC, so he has asked you to help him. Write a program to make sure that the grass in the field is perfectly cut: all parts of the field have to be mowed at least once when the mower goes from end to end, and again when the mower goes from side to side.
Input
Each test case contains 3 lines. The first line contains two integers,
The end of the test cases is signalled with a line that contains the numbers 0 0 0.0. You should generate no output for this line, as it is not a test case.
Real numbers for w, xi and yi can have up to 7 digits after the decimal point, and any cut will also include its boundaries. For example, if a 2.0-meter wide cut is performed along the 10.0-meter mark, then a strip of grass from 9.0 to 11.0 (including both) will be considered “cut”.
Output
Print YES if Guido has done a good job, or NO if some part of the field has not been mowed at least once when the mower was travelling along the length of the field, and again when it was travelling along the width.
Sample Input
8 11 10.00.0 10.0 20.0 30.0 40.0 50.0 60.0 70.00.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.08 10 10.00.0 10.0 20.0 30.0 40.0 50.0 60.0 70.00.0 10.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.04 5 20.070.0 10.0 30.0 50.030.0 10.0 90.0 50.0 70.04 5 20.060.0 10.0 30.0 50.030.0 10.0 90.0 50.0 70.00 0 0.0
Sample Output
YESNOYESNO
Hind
CSU-ACM2017暑期集训热身训练1
原题链接:VJ: B - Lawn mower
思路:将一连串割草机的位置坐标当作一个序列,查找序列中相邻位置的坐标的最大距离(由于位置坐标是乱序给出的,要先排序再查找),若大于割草机的宽度,说明存在草地没有割到,输出“NO”。(横向、纵向都要查)
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;#define maxn 1005double mini(double *s,int n) //查找最大距离{ double x=0; sort(s,s+n+2); for(int i=1; i<n+2; i++) x=(s[i]-s[i-1]>x)?(s[i]-s[i-1]):x; return x;}int main(){ int nx, ny; while(scanf("%d%d",&nx,&ny)==2 && (nx || ny)) { double w, x[maxn], y[maxn]; scanf("%lf",&w); x[0]=-w/2.0; x[1]=75.0+w/2.0; //边界处理 for(int i=2; i<nx+2; i++) scanf("%lf",&x[i]); y[0]=-w/2.0; y[1]=100.0+w/2.0; //边界处理 for(int i=2; i<ny+2; i++) scanf("%lf",&y[i]); if(mini(x,nx)>w || mini(y,ny)>w) printf("NO\n"); //比较 else printf("YES\n"); }}
- CSU: B
- CSU 1642 Problem B
- CSU - 1155 |a-b|
- CSU 1642 Problem B
- CSU 5月月赛B题
- csu Problem B: String and Arrays
- CSU 1000/1001/1002 A+B问题
- CSU-ACM2017暑假集训比赛1 B
- CSU-ACM2017暑假集训比赛2 B
- CSU-ACM2017暑假集训比赛7 B
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- java字符串类型引用与字符类型引用的面试案例
- Android——Fragment中键盘遮挡问题的解决方案
- springboot prop 优先级
- SpringMVC之HandlerMapping和HandlerAdapter
- 水题笔记:[OpenJudge1811]果断翻车
- CSU: B
- maven创建项目报错问题
- spring Quartz 源码分析--触发器类CronTriggerBean源码剖析
- GIT 学习 day03
- WooCommerce——怎么修改“添加到购物车”按钮的文字和链接
- JavaScript实现的可变动态数字键盘控件三种方式
- 高性能网络编程
- Codeforces
- java基础易错题