CSU1840-Lawn mower-简单模拟
2017-06-27 00:42
246 查看
Y: Lawn mower
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, nx (0 < nx < 1 000) and ny (0 < nx < 1 000), and a real number w (0Output
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.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 8 10 10.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 0.0 10.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 4 5 20.0 70.0 10.0 30.0 50.0 30.0 10.0 90.0 50.0 70.0 4 5 20.0 60.0 10.0 30.0 50.0 30.0 10.0 90.0 50.0 70.0 0 0 0.0
Sample Output
YES NO YES NO
其实仔细一想,就是指垂直和水平割草的时候都要全部覆盖一遍
一开始把eps写成1e2我是真的智障……
#include <bits/stdc++.h> #define N 10100 #define INF 0x3f3f3f3f #define LL long long #define mem(a,n) memset(a,n,sizeof(a)) #define fread freopen("in.txt","r",stdin) #define fwrite freopen("out.txt","w",stdout) double hor[1010],ver[1010]; using namespace std; int main() { // ios::sync_with_stdio(false); bool ok; int n,m,i; double wid; while(cin>>n>>m>>wid&&(n||m)){ for(i=0;i<n;++i){ cin>>hor[i]; } sort(hor,hor+n); for(i=0;i<m;++i){ cin>>ver[i]; } sort(ver,ver+m); ok=hor[0]-wid/2<1e-4&&(hor[n-1]-(75-wid/2)>-1e-7); // printf("%7f %7f\n",hor[0]-wid/2,hor[n-1]-(75-wid/2)); for(i=1;i<n-1&&ok;++i){ // cout<<hor[i]-hor[i-1]-wid<<endl; if(hor[i]-hor[i-1]-1e4>wid){ ok=false; // cout<<1; } } if(ok){ ok=(ver[0]-wid/2<1e-4)&&(ver[m-1]-(100-wid/2)>-1e-4); // printf("%7f %7f",ver[0],ver[m-1]); for(i=1;i<m 99a0 -1&&ok;++i){ // cout<<ver[i]-ver[i-1]-wid<<endl; if(ver[i]-ver[i-1]-wid>1e-4){ ok=false; // cout<<2; } } } if(ok){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } } return 0; } /********************************************************************** Problem: 1840 User: CSUzick Language: C++ Result: AC Time:16 ms Memory:1716 kb **********************************************************************/
相关文章推荐
- CSU 1339 最后一滴血 (简单模拟)
- CSU1732-XueXX and Binary-简单模拟
- CSU 1378 Shipura 简单模拟
- CSU 1765 简单shell 模拟
- QQ界面的简单模拟
- WinForm学习(1) --简单的模拟时钟程序
- 用AJAX实现google输入自动完成的简单模拟
- 在 ASP.NET 中用匿名委托简单模拟 AOP 做异常和日志处理
- WinForm学习 --简单的模拟时钟程序
- 半透明物体边缘透射的简单模拟
- 使用java简单模拟ping和telnet的实现
- [模拟] 简单的进程调度模拟
- 基于ODE的 简单的布料模拟demo
- 防止模拟键盘一类工具操作自己的系统的“简单实现”
- 使用java简单模拟ping和telnet的实现
- 使用java简单模拟ping和telnet的实现
- 用AJAX实现google输入自动完成的简单模拟
- JavaScript一点也不简单—实现“跨Frame的层模拟菜单”的方法(译文)
- 一个简单实用的模拟选项夹的代码
- 在ASP.NET 中模拟简单数字注册码的生成