No.635 Natural Kadomatsu Sequence
Definition
A sequence of 3 real numbers $v = (a_1,a_2,a_3)$ is said, according to legend, to be a Kadomatsu sequence when $v$ satisfies the following conditions.
- $a_1,a_2,a_3$ are all distinct
- $a_2$ is the largest or the smallest of the 3 elements
Problem Statement
Yukikoji discovered 3 bamboo stalks growing naturally, lined up in a row.
Upon observing the bamboo, Yukikoji found that the $i$-th stalk is currently $x_i$ [m] long and grows $y_i$ [m] per hour.
The growth rate is constant, and we do not consider the possibility of the stalks withering or breaking along the way.
Yukikoji wants to take a photograph of the moment when the lengths of the 3 bamboo stalks form a Kadomatsu sequence.
Does such a moment exist?
Output YES if there is a prospect of the lengths of the 3 bamboo stalks forming a Kadomatsu sequence, and NO otherwise.
Input
$N$ $testcase_1$ $testcase_2$ ... $testcase_N$
In this problem, a single input contains $N (1\le N \le 200)$ test cases separated by newlines.
The 1st line gives the number of test cases, and the 2nd through $N+1$-th lines give the test cases.
Each test case is given on a single line, separated by spaces, as follows.
$x_1$ $x_2$ $x_3$ $y_1$ $y_2$ $y_3$
$1 \le x_i \le 2020$
$1 \le y_i \le 2020$
All values are integers.
Output
For each test case, output YES if there is a prospect of the lengths of the 3 bamboo stalks forming a Kadomatsu sequence, and NO otherwise, separated by newlines.
Print a newline at the end.
Sample
Sample 1
Input
5 3 7 8 3 2 1 1 3 2 100 200 300 1 2 3 4 5 5 1 4 8 6 4 1 1 1 1 1 1 1
Output
YES YES NO YES NO
This input contains 5 test cases.
In the test case on the 1st line, the 3 bamboo stalks are currently 3m, 7m, and 8m long, and they grow 3m, 2m, and 1m per hour, respectively.
After 2 hours from now, the bamboo lengths are 9m, 11m, and 10m, which form a Kadomatsu sequence, so output YES.
In the test case on the 2nd line, the bamboo lengths already form a Kadomatsu sequence, so the answer is YES.
In the test case on the 3rd line, the bamboo lengths are always in ascending order, so output NO.
In the 4th line, a Kadomatsu sequence is formed after $11/8$ hours. The time interval during which the lengths of the 3 bamboo stalks form a Kadomatsu sequence does not necessarily contain an integer.
In the 5th line, all the bamboo lengths are always equal, so one of the conditions of a Kadomatsu sequence, "$a_1,a_2,a_3$ are all distinct", is never satisfied, and the answer is NO.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
はむこ