csu1840Lawn mower(水)
来源:互联网 发布:java语言 编辑:程序博客网 时间:2024/06/14 07:50
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 fi rst line contains two integers, nx (0 < nx < 1 000) and ny (0 < nx < 1 000), and a real number w (
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
#include<iostream>#include<algorithm>#include<cstdio>#include<cmath>#include<string.h>using namespace std;double xi[1005],yi[1005];int main(){ int nx,ny; double w; while(cin>>nx>>ny>>w) { bool suc=true; if(nx==0&&ny==0&&abs(w)<1e-5) break; for(int i=0;i<nx;i++) cin>>xi[i]; for(int i=0;i<ny;i++) cin>>yi[i]; sort(xi,xi+nx); sort(yi,yi+ny); double endx=xi[0]+w/2.0; double endy=yi[0]+w/2.0; for(int i=1;i<nx;i++) if(endx<xi[i]-w/2.0) { suc=false; break; } else endx=xi[i]+w/2.0; if(endx<75&&suc) suc=false; if(suc) { for(int i=1;i<ny;i++) if(endy<yi[i]-w/2.0) { suc=false; break; } else endy=yi[i]+w/2.0; if(endy<100) suc=false; } if(suc) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0;}
- csu1840Lawn mower(水)
- Uvalive 4954 Lawn mower
- CSU1840-Lawn mower-简单模拟
- UVALive 4954 Lawn mower (简单模拟题)
- 2017湖南多校第三场A(1025): Lawn mower
- 水
- 水
- 水
- 水
- 水
- 水
- 水
- 水
- 水
- 水
- 水,,
- 水~
- 水
- keras入门(一)
- 百度之星复赛--Arithmetic of Bomb----暴力
- 详细剖析浮点型运算的精度丢失
- Java 加解密中的对称加密详解
- NYOJ1058
- csu1840Lawn mower(水)
- GitHub命令的使用
- n&(n-1)的用法
- Maven的安装配置
- hdu2087-自己的理解&kmp讲解-剪花布条
- 【HDU1087】Super Jumping
- python windows下安装talib
- View那些事儿(1) -- View绘制的整体流程
- 浅谈OSSemPost()和OSSemPend()