A11085 | Rooter's Song
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Wherever the destination is, whoever we meet, let's render this song together.
On a Cartesian coordinate plane lies a rectangular stage of size $w×h$ , represented by a rectangle with corners $(0,0)$ , $(w,0)$ , $(w,h)$ and $(0,h)$ . It can be seen that no collisions will happen before one enters the stage.
On the sides of the stage stand $n$ dancers. The $i$ -th of them falls into one of the following groups:
- Vertical: stands at $(x_{i},0)$ , moves in positive $y$ direction (upwards);
- Horizontal: stands at $(0,y_{i})$ , moves in positive $x$ direction (rightwards).
According to choreography, the $i$ -th dancer should stand still for the first $t_{i}$ milliseconds, and then start moving in the specified direction at $1$ unit per millisecond, until another border is reached. It is guaranteed that no two dancers have the same group, position and waiting time at the same time.
When two dancers collide (i.e. are on the same point at some time when both of them are moving), they immediately exchange their moving directions and go on.
Dancers stop when a border of the stage is reached. Find out every dancer's stopping position.
On a Cartesian coordinate plane lies a rectangular stage of size $w×h$ , represented by a rectangle with corners $(0,0)$ , $(w,0)$ , $(w,h)$ and $(0,h)$ . It can be seen that no collisions will happen before one enters the stage.
On the sides of the stage stand $n$ dancers. The $i$ -th of them falls into one of the following groups:
- Vertical: stands at $(x_{i},0)$ , moves in positive $y$ direction (upwards);
- Horizontal: stands at $(0,y_{i})$ , moves in positive $x$ direction (rightwards).
According to choreography, the $i$ -th dancer should stand still for the first $t_{i}$ milliseconds, and then start moving in the specified direction at $1$ unit per millisecond, until another border is reached. It is guaranteed that no two dancers have the same group, position and waiting time at the same time.
When two dancers collide (i.e. are on the same point at some time when both of them are moving), they immediately exchange their moving directions and go on.
Dancers stop when a border of the stage is reached. Find out every dancer's stopping position.
输入格式
The first line of input contains three space-separated positive integers $n$ , $w$ and $h$ ( $1<=n<=100000$ , $2<=w,h<=100000$ ) — the number of dancers and the width and height of the stage, respectively.
The following $n$ lines each describes a dancer: the $i$ -th among them contains three space-separated integers $g_{i}$ , $p_{i}$ , and $t_{i}$ ( $1<=g_{i}<=2$ , $1<=p_{i}<=99999$ , $0<=t_{i}<=100000$ ), describing a dancer's group $g_{i}$ ( $g_{i}=1$ — vertical, $g_{i}=2$ — horizontal), position, and waiting time. If $g_{i}=1$ then $p_{i}=x_{i}$ ; otherwise $p_{i}=y_{i}$ . It's guaranteed that $1<=x_{i}<=w-1$ and $1<=y_{i}<=h-1$ . It is guaranteed that no two dancers have the same group, position and waiting time at the same time.
The following $n$ lines each describes a dancer: the $i$ -th among them contains three space-separated integers $g_{i}$ , $p_{i}$ , and $t_{i}$ ( $1<=g_{i}<=2$ , $1<=p_{i}<=99999$ , $0<=t_{i}<=100000$ ), describing a dancer's group $g_{i}$ ( $g_{i}=1$ — vertical, $g_{i}=2$ — horizontal), position, and waiting time. If $g_{i}=1$ then $p_{i}=x_{i}$ ; otherwise $p_{i}=y_{i}$ . It's guaranteed that $1<=x_{i}<=w-1$ and $1<=y_{i}<=h-1$ . It is guaranteed that no two dancers have the same group, position and waiting time at the same time.
输出格式
Output $n$ lines, the $i$ -th of which contains two space-separated integers $(x_{i},y_{i})$ — the stopping position of the $i$ -th dancer in the input.
输入输出样例
输入 #1
8 10 8 1 1 10 1 4 13 1 7 1 1 8 2 2 2 0 2 5 14 2 6 0 2 6 1
输出 #1
4 8 10 5 8 8 10 6 10 2 1 8 7 8 10 6
输入 #2
3 2 3 1 1 2 2 1 1 1 1 5
输出 #2
1 3 2 1 1 3
The first example corresponds to the initial setup in the legend, and the tracks of dancers are marked with different colours in the following figure.
In the second example, no dancers collide.
In the second example, no dancers collide.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted