#P5482. [JLOI2011] 不等式组

    ID: 4437 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2011各省省选平衡树树状数组吉林

[JLOI2011] 不等式组

Description

Wangwang and Wangmiao have recently been practicing some inequalities. These inequalities are all one-variable inequalities of the form ax+b>cax+b>c. Of course, solving such inequalities is too easy for Wangwang, so Wangmiao wants to challenge him.

Wangmiao gives a set of one-variable inequalities and a value. Wangwang needs to answer: when x=kx=k, how many inequalities in the set are satisfied. Clever Wangwang can give the answer quickly every time. Your task is to quickly verify whether Wangwang's answers are correct.

Input Format

The first line contains a positive integer nn, indicating that there will be nn lines following.

Each of the next lines can be in one of the following 33 forms:

  1. Add a b c: Add an inequality ax+b>cax+b>c to the system.
  2. Del i: Delete the ii-th added inequality (the first added one is 11).
  3. Query k: A query asking, when x=kx=k, how many inequalities in the current system are satisfied.

Note: Initially, the system is empty. a,b,c,i,ka,b,c,i,k are all integers. All operations are guaranteed to be valid: there will be no request to delete an inequality that has not been added, but the same inequality may be deleted repeatedly.

Output Format

For each query Query k, output one line with one integer, which is the answer to the query.

9
Add 1 1 1
Add -2 4 3
Query 0
Del 1
Query 0
Del 2
Query 0
Add 8 9 100
Query 10
1
1
0
0

Hint

Explanation of Sample 1

The first inequality added to the system is x+1>1x+1>1, and the second is 2x+4>3-2x+4>3. Therefore, in the first query, only the second inequality can be satisfied, so output 1.

Then delete the first inequality. In the next query, still only the second inequality can be satisfied, so output 11.

After deleting the second inequality, since the system contains no inequalities, none can be satisfied, so output 00.

Continue by adding the third inequality 8x+9>1008x+9>100. When x=k=10x=k=10, we have 8×10+9=89<1008\times 10+9=89<100, so no inequality can be satisfied, and the output is still 00.

Constraints

  • For 20%20\% of the data, n103n\leq 10^3.
  • For 40%40\% of the data, n104n\leq 10^4.
  • For 100%100\% of the data, 1n1051\leq n\leq 10^5, a,b,c[108,108]a,b,c\in[-10^8,10^8], k[106,106]k\in[-10^6,10^6].

Translated by ChatGPT 5