编程介的小学生 2018-12-19 19:54 采纳率: 20.5%
浏览 350
已采纳

这个算法,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条回答 默认 最新

  • threenewbee 2019-08-24 23:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示