当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6909:InkBall FX

题目描述
Recently, Jonathan is addicted to a game called InkBall FX.

The game goes on a plane coordinate system. On the first quadrant, there are some segments. The segments are all parallel to x-axis and they are pairwise disjoint. Two segments are disjoint if and only if they don’t have mutual point, including the end points. Therefore, we can use ($L_i,R_i,Y_i$) to note the $i^{th}$ segment, which means the segment starts from the position ($L_i,Y_i$) and ends in the position ($R_i,Y_i$).

There is an extremely small ball on the position (0,0). At the beginning, the speed of the ball in the horizontal direction is 1 per second, and that in the vertical direction is also 1 per second. If the ball is now at the position (x,y), then it will move to the position (x + t,y + t) after t seconds, if it does not touch the segment during this process.

When the ball hits any segment, a completely elastic collision occurs, which means the speed in vertical direction will be reversed and that in the horizontal direction will remain the same, since the segments are parallel to x-axis. After the collision, the segment will disappear, which means it cannot be collided twice.

If the ball hits the ends of the segment, the collision still occurs like what’s mentioned before.

Jonathan is curious about how many segments the ball could hit, but the ball moves too slow. Please write a program to help him to get the answer quickly.
输入解释
The first line contains one integer T (1 ≤ T ≤ 10) denoting the count of testcase.

For each testcase,

The first line contains one integer n (1 ≤ n ≤ $10^5$), representing the number of segments.

Then n lines follow. The i-th line contains three integers $L_i,R_i,Y_i$ (1 ≤ $L_i,R_i,Y_i$ ≤ $10^9,L_i < R_i$), representing the i-th segment.
输出解释
For each testcase, one line with an integer x - times that collision occurred.
输入样例
2
3
4 6 1
2 4 3
5 6 3
2
3 4 1
1 2 2
输出样例
2
2
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6909

最后修改于 2021-06-22T18:18:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
12000/6000MS(Java/Others) 262144/262144K(Java/Others)