longyitongxue's blog

By longyitongxue, history, 54 minutes ago, In English

A

Convert the value of $$$A+B$$$ to a string, and output the length of the string.

Code

B

Determine whether $$$k$$$ belongs to $$$(\min(a_i, a_{i+1}), \max(a_i, a_{i+1})]$$$.

Code

C

Just simulate the process of assigning IDs as required by the problem.

Code

D

After the transformation, we can see that it is Dijkstra. We only need to sort the vertices connected to the current vertex by their indices, then assign the edge connecting the smallest-indexed vertex to $$$0$$$ and the remaining edges to $$$1$$$, and finally run the template.

Code

E

We can solve this efficiently by finding the maximum number of points contained within a half-plane. To completely avoid precision issues and TLE, we use strictly integer operations, specifically long long cross products, instead of atan2 or floating-point math. We first sort the points by their polar angle using a custom comparator based on quadrants and cross products. To handle circular wraparound smoothly, we duplicate the sorted array. Finally, we use a two-pointer sliding window to find the maximum valid window. We move the right pointer forward as long as the cross product between the left point $$$A$$$ and the candidate right point $$$B$$$, calculated as $$$A_x \times B_y - A_y \times B_x$$$, is positive, which guarantees the angular span is strictly less than $$$180^\circ$$$.

Code
  • Vote: I like it
  • +2
  • Vote: I do not like it