bao987's blog

By bao987, history, 7 months ago, In English

Given a tree consisting of M vertices and N-1 weighted edges. The edges are numbered from 1 to N-1; the i-th edge connects the pair of vertices (u, v) and has weight c.

The path cost between two vertices (u, v) is the sum of the weights of the edges on the path from u to v (u ≠ v). If there is no path from u to v, the path cost for the pair (u, v) is 0.

An edge deletion method is described as follows:

Choose two positive integers L, R satisfying 1 ≤ L ≤ R ≤ N — 1;

Delete all edges numbered from L to R;

Given a positive integer K. An edge deletion method is called "beautiful" if every path cost between any pair of vertices does not exceed K. Two edge deletion methods are considered different if there is an edge present in one method but not in the other.

Requirement: Count the number of "beautiful" edge deletion methods. Constraints: N <= 1e5 Time limit: 1-2s

Sample input: 6 12

1 2 3

1 4 5

2 3 6

2 5 4

3 6 9

The answer is 9.

Please help me with this problem. Thank you very much. Here is the code for my smaller subtasks. Link: https://ide.usaco.guide/OaV3EO7Zu9DRl2APo19

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By bao987, history, 9 months ago, In English

We are given $$$n$$$ points $$$(x_i, y_i)$$$, each with a transmission radius $$$r_i$$$. If a point already has the signal, it will transmit the signal to another point if:

$$$ (x_i - x_j)^2 + (y_i - y_j)^2 \le r_i^2 $$$

or

$$$ (x_i - x_j)^2 + (y_i - y_j)^2 \le r_j^2 $$$

Once a point receives the signal, it will also start transmitting according to the same rule.

Task: Find the minimum number of points that must be directly connected to the signal so that, starting from these initially connected points, all $$$n$$$ points will eventually receive the signal.

Constraints

$$$ 1 \le n \le 2 \times 10^5 $$$
$$$ |x_i|, |y_i| \le 10^6 $$$
$$$ 1 \le r_i \le 10^6 $$$

Example:

3

1 0 1

2 0 1

5 0 1

Output:


2

Please help me with this problem, thank you very much.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By bao987, history, 10 months ago, In English

Consider a sequence a = a1, a2, ..., an of length n. The sequence a is called beautiful if it satisfies both of the following conditions:

  • For all i from 1 to n, the value of a[i] is between 1 and m, inclusive.

  • For all i from 1 to n — 1, a[i] is a divisor of a[i + 1].

Count how many such beautiful sequences exist.

Since the answer can be very large, output the result modulo 998244353.

Constraints:

1 ≤ n, m ≤ 3 × 10⁸

Time limit: 5s

Sample input:

3 6

Sample output:

25

Could you all please help me? I really appreciate it!

Full text and comments »

  • Vote: I like it
  • -9
  • Vote: I do not like it

By bao987, history, 10 months ago, In English

Hello everyone, today I’d like to ask a question related to computational geometry. I’d really appreciate your help. Thank you very, very much!

Problem summary:

You are given N convex polygons that are strictly nested — meaning some polygons are completely contained within others, forming a tree-like structure (polygon 1 is the outermost "root"). The polygons do not overlap, do not share edges, and each polygon either contains or is disjoint from others.

Each query gives a point (x, y). Your task is to find the polygon with the smallest area that contains this point.

Note: No point lies on the boundary of any polygon.

Input format:

The first line contains two integers: N and Q.

The next N lines describe the polygons. Each line starts with an integer k followed by 2k integers representing the k vertices in clockwise order: k x1 y1 x2 y2 ... xk yk

The last Q lines each contain a query point: x y

Input:

5 3

4 0 1 1 7 6 8 7 0

3 2 4 5 6 6 1

4 3 7 4 6 3 5 2 6

5 1 3 2 3 3 2 3 1 1 2

4 4 4 5 4 5 3 4 3

5 7

2 2

5 5

Output:

1

4

2

problem link: https://vjudge.net/problem/VNOJ-kingdoms

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it