Блог пользователя ankitkumar1234__

Автор ankitkumar1234__, история, 2 часа назад, По-английски

Author ~Hamed_Ghaffari, While reading Problem E in today's Codeforces Round 1124 (Div. 2), I noticed an interesting visual similarity to a problem concept I was working on recently. While Problem E focuses on a fixed range with a range maximum, my version involves arbitrary array rearrangement and full partitioning into disjoint subsets.

You are given an array $$$A$$$ of $$$N$$$ integers. You may rearrange the elements of $$$A$$$ in any arbitrary order to form a new array $$$A'$$$.

After rearranging, you must divide $$$A'$$$ into $$$m$$$ ($$$m \ge 1$$$) contiguous, disjoint subarrays $$$S_1, S_2, \dots, S_m$$$ such that every element of $$$A'$$$ belongs to exactly one subarray.

Let $$$F(S)$$$ denote the bitwise AND of all elements in a subarray $$$S$$$:

$$$F(S) = \bigwedge_{x \in S} x$$$

Version 1 (Feasibility Check): Given an integer $$$K$$$, determine if there exists a valid rearrangement and partition such that:

$$$F(S_1) \oplus F(S_2) \oplus \dots \oplus F(S_m) = K$$$

Version 2 (Maximization): Find the maximum possible value of:

$$$F(S_1) \oplus F(S_2) \oplus \dots \oplus F(S_m)$$$

among all valid rearrangements and partitions of $$$A$$$ .

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор ankitkumar1234__, история, 10 месяцев назад, По-английски

I’m stuck on the following dynamic MST problem.

You are given an undirected, weighted graph with N vertices and M edges. The graph will undergo Q dynamic operations. After every operation, you must output the total weight of the current Minimum Spanning Tree (MST). The test data guarantees that an MST always exists after every operation.

Initial Graph:

  • Vertices are numbered from 1 to N.
  • The graph initially contains M edges.
  • Each edge is specified as:   u v w   representing an undirected edge between u and v with weight w.

Query Types:

  1. U u v w   Update or insert an edge.   * If an edge (u, v) already exists, change its weight to w.   * Otherwise, insert a new edge (u, v) with weight w.

  2. D u v   Delete an edge between u and v, guaranteed that it always exist.

Output: After each query, print the total weight of the MST of the current graph. The input guarantees that the graph always remains connected, so an MST always exists.

Constraints: 1 ≤ N ≤ 200000 0 ≤ M, Q ≤ 200000 1 ≤ u, v ≤ N 1 ≤ w ≤ 1e9

Help me in solving in this problem.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится