APIO2019 brief explanations

Preface

Due to some amazing reason, we did not go to school all of this year \ (the APIO \) , so we take the time to do a bit this year's titleLike cushions for a long time

bridge

Blue chain topics

Description

Given a \ (n-\) points \ (m \) weighted undirected graph edges, you need to support two operations

  1. Modify the right edge of one side
  2. Inquiry begins with a point, not only through the side below a certain weight, how many points can be reached

\ (N \ leq 5 \ times 10 ^ 4, m, q \ leq 10 ^ 5 \)

Solution

Since this is a problem on the map with more complex and repair the problem, so we can think about how to do block

We can ask for a time block, then the prefix for the block and the current block are sorted in descending order according to weight, then we continue the prefix block edges is greater than the added weight of the current query and to check the set. Then enumerate modify operations in the current block, if it is currently asking the right time is greater than the weight of the current inquiry, but also added disjoint-set, pay attention to the end of the current inquiry out to undo modify operations in the current block

Mouth cool moment to realize crematorium

code(3.7k)

Strange device

Blue chain topics

Description

For any one time \ (T \) corresponds to a tuple \ (((T + \ lfloor \ FRAC {B} {} T \ rfloor) \ BMOD A, T \ BMOD B) \) , where \ (A , B \) is given parameters

Given \ (n-\) time period \ ([L_i, r_i] \) , and asked how many different tuples for all time located in a total period

\ (N \ leq 10 ^ 6 0 \ leq l_i \ leq r_i \ leq 10 ^ {18} \)

Solution

We may consider setting this cycle section tuple is \ (k \) , it is easy to list the congruence equation

\[ \begin{cases} t + \lfloor\frac{t}{B}\rfloor \equiv t + k + \lfloor\frac{t + k}{B}\rfloor \pmod A \\ t \equiv t + k \pmod B \end{cases} \]

By the \ ((2) \) of formula to give, \ (K \) of \ (B \) multiples, so we can \ ((1) \) of formula simplification

\[ \lfloor\frac{t}{B}\rfloor \equiv k + \lfloor\frac{t + k}{B}\rfloor \pmod A \\ \lfloor\frac{t}{B}\rfloor \equiv k + \lfloor\frac{t}{B}\rfloor + \frac{k}{B} \pmod A \\ k + \frac{k}{B} \equiv 0 \pmod A \\ \frac{k(B + 1)}{B} \equiv 0 \pmod A \]

According to the basic algorithm than with equations, we can continue its simplification

\[ \frac{k}{B} \equiv 0 \pmod {\frac{A}{(A, B + 1)}} \\ k \equiv 0 \pmod {\frac{AB}{(A, B + 1)}} \]

So the minimum cycle section is \ (\ dfrac {AB} {(A, B +. 1)} \) , so all we need to do a given interval in the interval coverage sense die can be a circular section

code(1.5k)

Street light

Blue chain topics

Description

Has a length \ (n-\) end sections, sections from \ (1 \) to the \ (n + 1 \) reference, some sections can be passed, you need to support two operations

  1. Changing the state of a segment, i.e., if could have elapsed, it becomes not elapsed, and vice versa
  2. Inquiry from \ (0 \) time start to the present time, a total number of times to meet the taxi from the endpoint \ (a \) to the endpoint \ (b \)

\(n, q \leq 3 \times 10^5\)

Solution

We can consider a \ (set \) to maintain a breakpoint, so you can quickly check the location of each position of the extreme left / right can be reached. Then we can ask each as a point on a two-dimensional plane, then a modification is a rectangular section affected by the operation, so it requires the equivalent of a historical versions. However, because this question of modifying the weights are the same, so we can each contribute to the current time to the end of time are counted up, the last time the query and then judge for themselves whether the current China Unicom on it. It is converted to a rectangular plus, single point of inquiry, it is directly \ (CDQ \) partition on it

code(3.1k)

Guess you like

Origin www.cnblogs.com/xunzhen/p/11576216.html