BNUOJ 34986 北京邀请赛 F题 Football on Table 几何题

来源:互联网 发布:mac迅雷下载失败提示 编辑:程序博客网 时间:2024/05/21 02:20


题目链接 : Click_here


"Bored? Let's play table football!"
The table football is played on a rectangular table, usually contains m rows of players which are plastic, metal, wooden, or sometimes carbon-fibre figures mounted on vertical metal bars. After playing table football for hours, we decide to take a rest. And the state of the table remains random, that means each bar is placed at any legal position with equal possibilities (players can’t be outside the table and a bar is fixed at a row).
 
 
Now I'm wondering if the goal-keeper shoot a ball, what’s the possibility of this shoot turning to a goal? (If the ball did not touch any player, then I made a goal).
Let's assume there is ai players on the ith row (counted from left to right). And we know the width of each player and the distance between two players. (To simplify the problem, we ignore the thickness of the players, in other words, we consider the players as vertical segments. Then we treat the football as a point, moving along a straight line and will not touch the boundary of the table).
 

Input

The first line contains an integer T, which denotes the number of test cases.
For each test case:
  • The first line contains two numbers L, W (1 ≤ L, W ≤ 108), denoting the length and the width of the table. (the lower left corner of the table is (0, 0) , and the top right corner of the table is (L, W)).
  • The second line contains four number X, Y, dx, dy. (X, Y) denotes the initial position of the ball and (dx, dy) denotes the shooting direction. (X will always be zero, 0 ≤ Y ≤ W, dx> 0).
  • The third line contains an integer m (1 ≤ m ≤ 10), the number of rows of the players.
  • Following m blocks, for the ith block,
    • The first line contains a number xi and an integer ai,(0<xi<L, 1 ≤ ai ≤ 100) denoteing the x-coordinate of the ith row and the number of players at the ith row.
    • The second line contains ai numbers, the jth number wj denotes the width of the jth (from bottom to top) player at the ith row.
    • The third line contains ai - 1 numbers, the jth number dj denotes the distance between the jth player and the (j+1)th player. If ai equals 1, this line will be a blank line.
We guarantee that ∑wj + ∑dj + 1< W
 

Output

For each case, first output the case number as "Case #x: ", and x is the case number. Then output the result rounded to 5 digits after the decimal point, representing the possibility of this shoot turning to a goal, in other words, that the ball does not touch any player.
 

Sample Input

28.0 10.00.0 5.0 2.0 -0.113.0 22.0 2.01.08.0 10.00.0 5.0 2.0 0.023.0 22.0 2.01.04.0 32.0 1.0 2.01.0 1.0

Sample Output

Case #1: 0.23000Case #2: 0.13333

Hint

The black solid lines denote the table.
The dashed line denotes the bar.
The gray lines denote the players.
The dot-dashed line denote the trajectory of the ball.
 

Source

2014 ACM-ICPC Beijing Invitational Programming Contest

只要读懂题目。。 算出 那个球在每个线上的活动范围。。 人的区域/活动范围就是被阻挡的概率。。   简单线条扫描一次就过了。。

#include <bits/stdc++.h>using namespace std;double W,L;double X,Y,dx,dy;int m;const double eps = 1e-9;const int N = 1111;double xi, ai;double xa[N],d[N];struct loc{double y;int is_end;loc(){}loc(double _y,int _is_end):y(_y),is_end(_is_end){}} lo[N]; int nl;double solve(){cin >> xi >> ai;double sum = 0;for(int i = 0;i < ai;i++){cin >> xa[i];sum += xa[i];}d[0] = 0.0; for(int i = 1;i < ai;i++){cin >> d[i];sum += d[i];}nl = 0;double pre = 0.0;for(int i = 0;i < ai;i++){pre += d[i];lo[nl++] = loc(pre,0);lo[nl++] = loc(pre+xa[i],1);pre += xa[i];}//for(int i = 0;i < nl; i++){//printf("lo[%d] = %.6lf \n",i,lo[i].y);//}double ny = (xi - X)*dy/dx + Y;double free_space = W - sum;double cc_use = 0; //  records prevented areadouble ty = ny;//printf("ny=%.6lf\n",ny);for(int i=nl-1; i >= 0;i--){if(lo[i].y > ny) continue;//printf("work ny=%.6lf\n",ny);if(i == nl-1){free_space -= ny - lo[i].y;if(free_space + eps < 0) break;ny = lo[i].y;}if(!lo[i].is_end){//printf("fuck : free_space = %.6lf ny=%.6lf\n",free_space,ny);if(free_space + eps < ny - lo[i].y){cc_use += free_space;break;}else cc_use += ny - lo[i].y;free_space -= ny - lo[i].y;ny = lo[i].y;}else{//printf("amazing: fuck : free_space = %.6lf ny=%.6lf\n",free_space,ny);if(free_space + eps < ny - lo[i].y){break;}free_space -= ny - lo[i].y;ny = lo[i].y;}//printf("free_space = %.6lf ny=%.6lf\n",free_space,ny);}return (W-sum-cc_use) / (W-sum);}int main(){int cas,tt=0;scanf("%d",&cas);while(cas--){cin >> L >> W;cin >> X >> Y >> dx >> dy;cin >> m;double ans = 1.0;while(m--){ans = ans *= solve();}printf("Case #%d: %.5lf\n",++tt,ans);}return 0;}


0 0
原创粉丝点击