Meter garlic off your first game 2019CSP film

First count of garlic off 2019CSP game

The game cleverly avoiding ......

T1 shelling

Title Description

\ (rize \) is a lovely girl.

One day, \ (RIZE \) shelling exercises. Target for bombardment by a circle, which has \ (\ n-1) th circle concentric target, the target being divided into separate \ (n-\) regions. From these regions to the outer \ (1 \) to the \ (n-\) number, the \ (I \) outer diameter regions of \ (R_i \) . Each region has a score of \ (I \) fraction of regions \ (S_I \) . \ (rize \) launched \ (m \) rounds. On the target plane to the origin of the bull's-eye Cartesian coordinate system, the \ (I \) shells hit region a radius \ (r_i \) circle, its center coordinates of \ ((x_i, y_i ) \) . If an area of the target area and one shell hit the intersection exists, then launch The cannon will get scores in the region. Here it does not include border area.

\ (rize \) want to know the score of each launch a projectile.

Input Format

The first two row numbers \ (n-, m \) ;
after \ (n-\) lines of two integers \ (R_i, S_I \) ;
after \ (m \) lines of three integers \ ( x_i, y_i, r_i \) .

Output Format

\ (m \) lines, each line represents a number of answers.

data range

There \ (30 \% \) data \ (n-, m \ Le 1000 \) ;

Another \ (20 \% \) data \ (= r_i. 1 \) ;

Another \ (20 \% \) data \ (= S_I. 1 \) ;

对于\ (100 \% \)的数据, \ (1 \ k, m \ 2 \ Times 10 ^ 5 \) , \ (1 \ the s_i \ 10 ^ 4 \) , \ (- 10 ^ 7 \ the x_i, y_i \ 10 ^ 7 \) , \ (1 \ the r_i \ 10 ^ 7 \) , \ (1 \ the R_1 <R_2 <\ cdots <R_n \ 10 ^ 7 \)

"This is a flood problem."
I did say so, but until the end I did not write this or konjac out ......

Binary search \ (+ \) prefix and

We can find, for each of rounds, we do not need to calculate the size of the circle, the real needs of the operator and only its center bull's-eye distance of plus or minus connection, respectively, its radius: \ (\ sqrt {X ^ 2 + Y ^ 2} + r \) is the farthest point, the closest point determination Laid need, when \ (\ sqrt {x ^ 2 + y ^ 2} <r \) when the center of the nearest point, otherwise \ (\ sqrt {x Y ^ 2 + 2 ^} - R & lt \) , then consider optimization, and the prefix can be used, and in consideration of how to find a prefix, it is conceivable \ (logN \) to find about half ...... quite

Code:

#include<bits/stdc++.h>
using namespace std;
#define rint register int
#define lb lower_bound
#define ub upper_bound 
int n, m;
int f[300010], c[300010];
inline int read( void ){
    int re = 0, f = 1;char ch = getchar();
    while( ch > '9' || ch < '0' ){
        if( ch == '-' ) f = -1;
        ch = getchar();
    }
    while( ch >= '0' && ch <= '9' ){
        re = re * 10 + ch - '0';
        ch = getchar();
    }
    return re * f;
}
int main( void ){
    n = read(); m = read();
    for( rint i = 1; i <= n; i++ ){
        c[i] = read(); 
        f[i] = read() + f[i - 1];
    }
    for( rint i = 1; i <= m; i++ ){
        double x, y;
        int r;
        x = read(); y = read(); r = read();
        double dis = sqrt( x * x + y * y );
        printf("%d\n",f[lb(c,c+n,(int)ceil(dis)+r)-c]-(dis<=r?0:f[ub(c+1,c+n+1, (int)dis-r)-c-1]));
    }
    return 0;
}

T2 travel

Okay, come up with a positive solution, we did not expect treatment

Title Description

\ (syaro \) is a lovely girl.

\ (syaro \) cities where there \ (n \) common between the blocks, blocks \ (m \) road two-way traffic, and any two blocks can reach each other through these roads.

One day, \ (syaro \) wants to bring countless rabbits from \ (1 \) went District No. \ (n \) No. neighborhoods. Since \ (syaro \) can not manage too many rabbits, so she decided that if there is a length of the road after she \ (w \) path, then only with her departure is not greater than \ (w \) rabbits . To save time, she will choose a walk in the total length of the shortest number of paths.

In addition, there \ (k \) blocks due to open a lot of coffee shops, the whole neighborhood is filled with the smell of coffee. Since \ (syaro \) smell the smell of coffee will be lost, so she will never shortest path through any one of these neighborhoods selected a walk. If all shortest path will go through this neighborhood, she would give up travel.

\ (syaro \) told \ (cocoa \) their travel plans. \ (cocoa \) as a good at arithmetic girl, wondering \ (syaro \) up to the number of rabbits with. Of course, giving up means up to travel with \ (0 \) rabbits.

Input format
of the first row of three numbers \ (n-, m, K \) ;

The second line \ (k \) number, lot number represents opened a neighborhood coffee shop;

After $ m $ rows, each row of three numbers \ (U, V, W \) , expressed from a \ (U \) to \ (V \) length \ (W \) road.

Output format
output line of a number indicates the answer.

Data range
for \ (10 \% \) data \ (n-, m \ Le 50 \) , \ (Mn \ Le 10 \) ;

For \ (30 \% \) data \ (n-, m \ Le. 3 ^ 10 \)
;

For \ (60 \% \) data \ (n-, m \ Le. 5 ^ 10 \)
;

Another \ (20 \% \) data \ (K = 0 \) ;

For \ (100 \% \) data \ (. 1 \ n-Le, m \ Le. 6 10 ^ \)
, \ (0 \ Le K \ Le n0≤k≤n, 0 \ Le W \ n-CDOT \ Le 10 ^ 9 \)
. Heavy edges is not warranted, to ensure that no loopback.

Obviously this problem is to make the point there is a coffee shop and do not mark them with even edges
and then find it in the new chart of the largest in the shortest edge

At that time do not know how to think, ran a half answer, half the length of the sides, in fact, the guarantee of correctness, but each half to run a \ (O (nlogn) \) The \ (Dij \) , \ (1e6 \) ran a \ (O (nlogn) \) no problem, so I deserved to ignore the front of that half of the answer \ (O (logn) \) , only a \ (O (logn) \) is not but \ (O (logn ^ 2) \) have to think about it, plus garlic customer evaluation Kyi meter run fast, I almost did not take the points lead

A standard should be \ (dp \)

Unfinished ......

Guess you like

Origin www.cnblogs.com/with6676/p/11809663.html