G-WindTime Limit: 3000/2000 ms (Java/Other) Memory Limit: 65535/32768 K (Java/Other) Total Submission (s): 123 Accepted Submission (s): 13 Font: times New Roman | Verdana | GeorgiaFont Size: Batch → Problem DescriptionN trees and M mushrooms in a row. each tree has its own coordinates and height, and each mushroom has its own coordinates and weights. A strong wind blew in, each tree has a probability of Li % to the left, there is a probability of Ri % to the right, there is (1-Li %-Ri %) the probability is not inverted. if a tree with H coordinates X falls down to the left, the mushroom in the range [X-H, X) will be smashed. If it falls down to the right, then the mushrooms whose coordinates are in the range (X, X + H] will be hit. please The expected value of the sum of the values of all the mushrooms that are not hit by a tree. The first line of Input contains two integers N, M.

Next N rows, 4 integers X, H, L, R. it indicates the coordinates of the tree, the height and the probability of inverted to the left and right. that is to say, this tree has a probability of L % to the left, and the probability of R % to the right.

In the next M row, there are two integers, Y and W, representing the coordinates and weights of the mushroom.

[Data range]

For 20% of data, 1 <= N, M <= 1000;

For 100% of the data, 1 <= N <= 10 ^ 5, 1 <= M <= 10 ^ 4, the absolute values of the coordinates of the tree and mushroom do not exceed 10 ^ 9, the height of the tree is within the range of [1, 10 ^ 9]. The weight of each mushroom is within the range of [1, 1000]. The L and R values of each tree are 0 <= L, r, L + R <= 100. output outputs an integer, which is the final answer. retain four decimal places. sample Input

1 12 2 50 501 1

Sample Output

0.5000

Probability Theory is almost forgotten, and I don't remember the expected variance standard deviation at all. Expectation, variance is here. If you have time for this background knowledge, I must make up for it.

The expectation for this question is E = Σ xi * pi, which is the formula. I started to write a pure brute force code. I first enumerated mushrooms and then enumerated trees. About 10 s. Later, I modified the interval sorting of the tree (I found that the sorting is completely ineffective. Pay attention to the limitations of this two-dimensional sorting in the future. The right end of the row range cannot constrain the changes on the left end of the interval, so it is not easy to break .), the enumeration tree uses binary query, but cannot be break. It takes 3.75 s. I asked my school girl, saying it was purely violent. Think about it too. The mushroom is a one-dimensional one, and break is very convenient. I wrote a 3.00 s. This is quite depressing. Then I wrote a binary query and optimized it to time: 0.265000. Well... the task is finished.

PS: the mark is really bad!

#include<iostream>#include<cstdio>#include<algorithm>#include<time.h>using namespace std;struct tree{ int x,h; double l,r;}t[111111];struct segment{ int l,r; double p;}seg[222222];struct node{ int x,v;}no[11111];bool cmp( node a,node b ){ return a.x<b.x;}int bisearch( int x,int n ){ int l=0,r=n,m; while( m=(l+r)/2,l<r ) { if( no[m].x>x ) r=m-1; else l=m+1; } return m;}int main(){ freopen( "Wind7.in","r",stdin ); freopen( "date.out","w",stdout ); int n,m; clock_t start,end; double time; start=clock(); while( scanf("%d %d",&n,&m)!=EOF ) { for( int i=0;i<n;i++ ) { scanf( "%d %d %lf %lf",&t[i].x,&t[i].h,&t[i].l,&t[i].r ); t[i].r/=100; t[i].l/=100; } for( int i=0;i<m;i++ ) scanf( "%d %d",&no[i].x,&no[i].v ); sort( no,no+m,cmp ); double ans=0,p;/** for( int i=0;i<m;i++ ) { p=1; int j=bisearch(no[i].x,2*n ); for( ;j<n*2;j++ ) { /** if( no[i].x>=t[j].x-t[j].h && no[i].x<=t[j].x ) p*=1-t[j].l; else if( no[i].x>=t[j].x && no[i].x<=t[j].x+t[j].h ) p*=1-t[j].r; / if( no[i].x>=seg[j].l && no[i].x<=seg[j].r ) p*=1-seg[j].p; //if( no[i].x<seg[j].l ) // break; } ans+=p*no[i].v; }*/ double a[11111]; for( int i=0;i<m;i++ ) a[i]=1; for( int i=0;i<n;i++ ) { int j=bisearch(t[i].x-t[i].h,m); for( ;j<m;j++ ) { if( t[i].x-t[i].h<=no[j].x && no[j].x<t[i].x ) a[j]*=1-t[i].l; if( t[i].x<no[j].x && no[j].x<=t[i].x+t[i].h ) a[j]*=1-t[i].r; if( no[j].x>t[i].x+t[i].h ) break; } } for( int i=0;i<m;i++ ) ans+=a[i]*no[i].v; printf( "%.4lf\n",ans ); } end=clock(); time=(double)(end-start)/CLOCKS_PER_SEC; printf( "time:%lf\n",time ); return 0;}