CF1729A.Two Elevators
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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=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.
弗拉德走进了他所住的公寓楼入口,此时他位于第 1 层。他打算呼叫电梯上楼回到自己的公寓。
这座楼里只有两部电梯。弗拉德确切地知道:
- 第一部电梯当前停在第 a 层(静止不动);
- 第二部电梯当前位于第 b 层,并正驶向第 c 层(b=c)。请注意,若 b=1,则该电梯已离开第 1 层,弗拉德来不及进入。
若呼叫第一部电梯,它将立即开始向第 1 层移动;若呼叫第二部电梯,则它会先抵达第 c 层,之后才前往第 1 层。每部电梯从第 x 层移动到第 y 层需要 ∣x−y∣ 秒。
弗拉德希望呼叫更快到达他所在位置(第 1 层)的那部电梯。请帮他选出这部电梯。
输入格式
The first line of the input contains the only t (1≤t≤104) — the number of test cases.
This is followed by t lines, three integers each a, b and c (1≤a,b,c≤108, b=c) — floor numbers described in the statement.
输入的第一行包含一个整数 t(1≤t≤104)——测试用例的数量。
接下来是 t 行,每行包含三个整数 a、b 和 c(1≤a,b,c≤108,且 b=c)——题目描述中提到的楼层号。
输出格式
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).
输出 t 个数字,每个数字对应一个测试用例的答案。答案定义如下:
- 若呼叫第一台电梯更优,则输出 1;
- 若呼叫第二台电梯更优,则输出 2;
- 若呼叫哪台电梯都一样(两台电梯将同时到达),则输出 3。
输入输出样例
输入#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.
在示例的第一个测试用例中,第一台电梯已位于 1 楼。
在示例的第二个测试用例中,当发出呼叫时,电梯的移动过程如下:
- 呼叫发生时刻,第一台电梯位于 3 楼,第二台电梯位于 1 楼,但此时已正驶向其他楼层;
- 呼叫发生 1 秒后,第一台电梯将到达 2 楼,第二台电梯也将抵达 2 楼,此时便可前往 1 楼;
- 呼叫发生 2 秒后,任一台电梯均可到达 1 楼。
在示例的第三个测试用例中,第一台电梯将在 2 秒后到达,第二台电梯将在 1 秒后到达。
输入解题思路,AI测评打分。不知道怎么写?