問題一覧 > 通常問題

No.635 Natural Kadomatsu Sequence

レベル : / AI推定難易度 : 1100 / 実行時間制限 : 1ケース 0.650秒 / メモリ制限 : 128 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 52
作問者 : mai / テスター : はむこ
お気に入りにしたユーザー ProblemId : 1478 / 自分の提出
問題文最終更新日: 2026-06-29 11:51:35
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 180 (順位表) の他の問題:

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.

  1. $a_1,a_2,a_3$ are all distinct
  2. $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もしくは右上の雲マークをクリックしてアカウントを作成してください。