这个算法,C语言怎么计算矩形的变得移动,用C语言

Problem Description
Xuejiejie loves to eat fish. One day, she goes to a pond for fishing. The pond can be seen as a two-dimensional surface, and her fishing net can be seen as a rectangle. One of the edges of the rectangle is parallel to the x-axis ,and another is parallel to y-axis. The fishes can be seen as points. Sometimes the fishes will enter the net, and sometimes they will leave the net. So, Xuejiejie doesn't know the appropriate time to draw the net in when she will get as many fishes as possible.

Xuejiejie assigns each fish with a number, from 1 to n, n being the total number. There are 2 types of movements of the fishes:

1 l r d : the fishes index between the interval [l,r] moved towards the x-axis for length d (For example , if a fish's current position is (x,y) , after moving , its position will change to (x+d,y). )

2 l r d : the fishes index between the interval [l,r] moved towards the y-axis for length d (For example , if a fish's current position is (x,y), after moving , its position will change to (x,y+d). )

And sometimes Xuejiejie will ask you some questions.

Input
In the first line there is an integer T, indicates the number of test cases.

In each case:

The first line includes an integer n indicating the total number of fish.

The second line includes 4 integers x1,y1,x2,y2,indicating the position of the fishing net. (x1,y1) means the lower-left position, and (x2,y2) means the top-right position.

The next n lines: each line includes x[i],y[i]; means the fish i's initial position.

The next line includes an integer m.

The next m lines describe the events you have to deal with.

In each line the first integer is c (1≤c≤3), which indicates the type of events.

1 l r d : the fish index between the interval [l,r] moved towards the x-axis for length d

2 l r d : the fish index between the interval [l,r] moved towards the y-axis for length d

3 l r : query the number of the fish index between the interval [l,r] which are in the net(including the one in the border)

1≤n,m≤100000, 1≤l≤r≤n. 1≤d≤109, x1≤x2, y1≤y2。 Ensure that any time all involved coordinate values in the range of[−109,109]。

Output
In each case:

For each type 3 events, output a integer which means the answer.

Sample Input
1
5
1 1 5 5
1 1
2 2
3 3
4 4
5 5
3
3 1 5
1 2 4 2
3 1 5

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!