#P5859. 「SWTR-3」Plane Mirrors

「SWTR-3」Plane Mirrors

Description

Student A\mathrm{A} dreams that he is standing on a platform. Around him there are some plane mirrors, and we assume his position is (0,0)(0,0).

He finds that each plane mirror has an initial opacity, denoted by viv_i.

In what follows, we define:

  • The “opacity” of a ray as: the sum of the initial opacities of all plane mirrors that the ray passes through.

  • The “visual opacity” of a plane mirror as: the maximum opacity among all rays that originate from (0,0)(0,0) and pass through that plane mirror.

Student A\mathrm{A} suddenly discovers that he can control these plane mirrors, so the following problem arises.

Student A\mathrm{A} needs you to perform the following operations:

1 x1 y1 x2 y2 v: Create a plane mirror whose two endpoints are at (x1,y1),(x2,y2)(x_1,y_1),(x_2,y_2), with initial opacity vv.

2 d: Destroy the dd-th created plane mirror. It is guaranteed that it has not been destroyed.

3 x y: Let A=(0,0),B=(x,y)\mathrm{A=(0,0),B=(x,y)}. Query the opacity of the ray AB\mathrm{AB}.

4 d: Query the visual opacity of the dd-th plane mirror. If it has been destroyed, output oops!.

Input Format

The first line contains an integer nn, denoting the number of operations.

The next nn lines: the ii-th line starts with an integer optopt, and then:

  • If opt=1opt=1, five integers x1,y1,x2,y2,vx_1,y_1,x_2,y_2,v.

  • If opt=3opt=3, two integers x,yx,y.

  • Otherwise, one integer dd.

Output Format

For each query of type 33 or 44, output one line with the answer.

11
1 -1 2 2 -1 7
1 2 2 -1 0 10
1 2 1 1 -1 17
3 5 4
3 -99999 0
3 -3 6
3 1 -1
4 2
2 1
4 2
4 1

7
10
17
17
17
10
oops!

Hint


Sample Explanation

As shown in the figure, blue represents rays and red represents plane mirrors.

For the 1st query: we can see the ray only passes through plane mirror 11, so the answer is 77.

For the 2nd query: we can see the ray only passes through plane mirror 22, so the answer is 1010.

For the 3rd query: we can see the ray passes through plane mirrors 1,21,2, so the answer is 7+10=177+10=17.

For the 4th query: we can see the ray passes through plane mirror 33, so the answer is 1717.

For the 5th query: we can see that among rays passing through plane mirror 22, the ray with the maximum opacity is (0,0)(2,2)(0,0)(2,2) (the ray is not unique). It passes through plane mirrors 1,21,2, so the answer is 7+10=177+10=17.

For the 6th query: we can see that among rays passing through plane mirror 22, the ray with the maximum opacity is (0,0)(2,2)(0,0)(2,2) (the ray is not unique). It passes through plane mirror 22, so the answer is 1010.

For the 7th query: since plane mirror 11 has been destroyed, output oops!.


Constraints and Notes

Test point ID nn\leq Special property
141-4 10001000 $
585-8 2×1052\times 10^5 all yy are equal
9129-12 x0x\ge 0
132013-20 none

For 100%100\% of the testdata, 1n2×1051\leq n\leq 2\times 10^5, 1v1031\leq v\leq 10^3, and 0x,y1050\leq |x|,|y|\leq 10^5.

It is guaranteed that the total number of plane mirrors will not exceed 10510^5.

It is guaranteed that no plane mirror passes through (0,0)(0,0), but it is not guaranteed that a plane mirror will not degenerate into a point.

It is guaranteed that for all type 33 queries, (x,y)(0,0)(x,y)\neq(0,0).


For all test points, the time limit is 2s2\mathrm{s} and the memory limit is 128MB128\mathrm{MB}.

Translated by ChatGPT 5