2017湖南多校第三场A(1025): Lawn mower
2017-03-19 17:27
309 查看
A(1025): Lawn mower
Submit Page Summary Time Limit: 1 Sec Memory Limit: 128 Mb Submitted: 28 Solved: 22
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.
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 (0<w≤50), which represents the width of the cut of that particular lawn mower. The next line describes the end-to-end passes (along the length of the field), and contains nx real numbers xi (0≤xi≤75) describing the starting positions of the mower’s center in Guido’s end-to-end passes. The last line describes the side-to-side passes, with ny real numbers yi (0≤yi≤100).
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.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
解题思路:排序判断
Submit Page Summary Time Limit: 1 Sec Memory Limit: 128 Mb Submitted: 28 Solved: 22
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 (0<w≤50), which represents the width of the cut of that particular lawn mower. The next line describes the end-to-end passes (along the length of the field), and contains nx real numbers xi (0≤xi≤75) describing the starting positions of the mower’s center in Guido’s end-to-end passes. The last line describes the side-to-side passes, with ny real numbers yi (0≤yi≤100).
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.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
解题思路:排序判断
#include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<algorithm> #include<queue> #include<string> #include<map> #include<bitset> #include<set> #include<cstdlib> #include<ctime> using namespace std; typedef long long LL; const int MAXN=1000000000; double len[1005],wid[1005]; int main() { ios::sync_with_stdio(false); cin.tie(0); int nx,ny; double w; while(cin>>nx>>ny>>w) { //cout<<nx<<ny<<w; memset(len,0,sizeof(len)); memset(wid,0,sizeof(wid)); if(nx==0&&ny==0&&w==0.0) break; for(int i=1;i<=nx;i++) { cin>>len[i]; } for(int i=1;i<=ny;i++) { cin>>wid[i]; } sort(len+1,len+nx+1); sort(wid+1,wid+ny+1); bool flag=true; if(len[1]>w/2||len[nx]<75-w/2||wid[1]>w/2||wid[ny]<100-w/2) flag=false; if(flag) { for(int i=2;i<=nx;i++) { if(len[i]-len[i-1]>w) { flag=false; break; } } } if(flag) { for(int i=2;i<=ny;i++) { if(wid[i]-wid[i-1]>w) { flag=false; break; } } } if(flag) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
相关文章推荐
- 2017湖南多校第三场
- 2017 计蒜之道 初赛 第三场 A. 腾讯课堂的物理实验
- 2017 计蒜之道 初赛 第三场 腾讯狼人杀(简单)(暴搜)
- 2017湖南多校第十三场-COJ1963-Feed the rabbit
- 2017年多校联合训练 第三场(洪华敦)
- [最大密度子图] 2017 计蒜之道 初赛 第三场 腾讯狼人杀
- 2017 计蒜之道 初赛 第三场 A. 腾讯课堂的物理实验
- 2017 计蒜之道 初赛 第三场 腾讯狼人杀(简单)(暴搜)
- 2017湖南多校第四场-C(1037): Pizza Pricing
- 2017 国庆湖南 Day1
- 2017多校训练赛第三场 HDU 6061(NTT模板)
- 2017湖南多校第二场-20170312
- 2017 计蒜之道 初赛 第三场 腾讯狼人杀(简单)(暴搜)
- 2017湖南多校第一场-L(1011): Languages
- 2017湖南多校第四场-H(1042): Crash and Go(relians)
- [最大密度子图] 2017 计蒜之道 初赛 第三场. 腾讯狼人杀
- 2017 多校训练第三场 HDU 6058 Kanade's sum
- 2017 国庆湖南 Day6
- 2017 计蒜之道 初赛 第三场 腾讯狼人杀(简单)(暴搜)
- [2017湖南集训7-9]大佬的问题 (数点问题)