#P16805. [蓝桥杯 2026 国 Python A] 算电协同

[蓝桥杯 2026 国 Python A] 算电协同

Problem Description

In 20262026, “computing-power and electricity coordination” was written into the government work report for the first time, and together with ultra-large-scale intelligent computing clusters, it was listed as a national-level new infrastructure project, supporting the construction of a nationwide integrated computing-power scheduling system. During the project implementation, national computing-power hub nodes need to manage a large number of computing units in real time.

Each computing unit has an energy-efficiency value vv in the form of a non-negative integer. To optimize energy scheduling, the scheduling system needs to count the number of pairs of units that satisfy the “coordination condition”. Define two computing units (i,j)(i, j) as a coordinated pair if and only if:

  • i<ji < j;
  • $\text{Fib}(v_i + v_j) = \text{Fib}(v_i) + \text{Fib}(v_j)$.

Here, Fib(x)\text{Fib}(x) denotes the xx-th Fibonacci number. The Fibonacci sequence is defined as follows:

  • Fib(0)=0\text{Fib}(0) = 0;
  • Fib(1)=1\text{Fib}(1) = 1;
  • For x≥2x \ge 2, Fib(x)=Fib(x−1)+Fib(x−2)\text{Fib}(x) = \text{Fib}(x-1) + \text{Fib}(x-2).

Now, you need to maintain an initially empty pool of computing units and process qq operations:

  • 1 k v1\ k\ v: Add kk computing units with energy-efficiency value vv.
  • 2 k v2\ k\ v: Remove at most kk computing units with energy-efficiency value vv. If there are fewer than kk units with value vv, remove all of them.
  • 33: Query how many coordinated pairs of units there are in total at the moment.

Please write a program to simulate the operation of this scheduling system and output the corresponding result for each query.

Input Format

The first line contains a positive integer qq, indicating the number of operations.
The next qq lines each describe one operation:

  • 1 k v1\ k\ v: Add kk units with value vv.
  • 2 k v2\ k\ v: Remove at most kk units with value vv.
  • 33: Query the current total number of coordinated pairs.

Output Format

For each operation 33, output one line containing one integer, indicating the current total number of coordinated pairs.

5
1 2 0
1 3 1
3
2 4 0
3
7
0

Hint

Constraints and Notes

For 30%30\% of the testdata, 1≤q≤1031 \le q \le 10^3, 1≤k≤101 \le k \le 10.

For all testdata, 1≤q≤2×1051 \le q \le 2 \times 10^5, 0≤v≤1090 \le v \le 10^9, 1≤k≤1031 \le k \le 10^3.

Translated by ChatGPT 5