您的位置:首页 > 其它

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 fi rst line contains two integers, nx (0 < nx < 1 000) and ny (0 < nx < 1 000), and a real number w (0

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.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
**********************************************************************/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: