A15278 | Two Elevators
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vlad went into his appartment house entrance, now he is on the $1$ -th floor. He was going to call the elevator to go up to his apartment.
There are only two elevators in his house. Vlad knows for sure that:
- the first elevator is currently on the floor $a$ (it is currently motionless),
- the second elevator is located on floor $b$ and goes to floor $c$ ( $b \ne c$ ). Please note, if $b=1$ , then the elevator is already leaving the floor $1$ and Vlad does not have time to enter it.
If you call the first elevator, it will immediately start to go to the floor $1$ . If you call the second one, then first it will reach the floor $c$ and only then it will go to the floor $1$ . It takes $|x - y|$ seconds for each elevator to move from floor $x$ to floor $y$ .
Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
There are only two elevators in his house. Vlad knows for sure that:
- the first elevator is currently on the floor $a$ (it is currently motionless),
- the second elevator is located on floor $b$ and goes to floor $c$ ( $b \ne c$ ). Please note, if $b=1$ , then the elevator is already leaving the floor $1$ and Vlad does not have time to enter it.
If you call the first elevator, it will immediately start to go to the floor $1$ . If you call the second one, then first it will reach the floor $c$ and only then it will go to the floor $1$ . It takes $|x - y|$ seconds for each elevator to move from floor $x$ to floor $y$ .
Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.
输入格式
The first line of the input contains the only $t$ ( $1 \le t \le 10^4$ ) — the number of test cases.
This is followed by $t$ lines, three integers each $a$ , $b$ and $c$ ( $1 \le a, b, c \le 10^8$ , $b \ne c$ ) — floor numbers described in the statement.
This is followed by $t$ lines, three integers each $a$ , $b$ and $c$ ( $1 \le a, b, c \le 10^8$ , $b \ne c$ ) — floor numbers described in the statement.
输出格式
Output $t$ numbers, each of which is the answer to the corresponding test case. As an answer, output:
- $1$ , if it is better to call the first elevator;
- $2$ , if it is better to call the second one;
- $3$ , if it doesn't matter which elevator to call (both elevators will arrive in the same time).
- $1$ , if it is better to call the first elevator;
- $2$ , if it is better to call the second one;
- $3$ , if it doesn't matter which elevator to call (both elevators will arrive in the same time).
输入输出样例
输入 #1
3 1 2 3 3 1 2 3 2 1
输出 #1
1 3 2
In the first test case of the example, the first elevator is already on the floor of $1$ .
In the second test case of the example, when called, the elevators would move as follows:
- At the time of the call, the first elevator is on the floor of $3$ , and the second one is on the floor of $1$ , but is already going to another floor;
- in $1$ second after the call, the first elevator would be on the floor $2$ , the second one would also reach the floor $2$ and now can go to the floor $1$ ;
- in $2$ seconds, any elevator would reach the floor $1$ .
In the third test case of the example, the first elevator will arrive in $2$ seconds, and the second in $1$ .
In the second test case of the example, when called, the elevators would move as follows:
- At the time of the call, the first elevator is on the floor of $3$ , and the second one is on the floor of $1$ , but is already going to another floor;
- in $1$ second after the call, the first elevator would be on the floor $2$ , the second one would also reach the floor $2$ and now can go to the floor $1$ ;
- in $2$ seconds, any elevator would reach the floor $1$ .
In the third test case of the example, the first elevator will arrive in $2$ seconds, and the second in $1$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted