#K51002. Ordered Students
Ordered Students
Ordered Students
You are given groups of three students. Each student is represented by three integer scores. The task is to decide whether the students in each group can be ordered so that for every adjacent pair of students, the following conditions hold:
- For every subject (score), the score of the later student is not less than that of the earlier student, i.e. \( s_i[j] \le s_{i+1}[j] \) for \( j=1,2,3 \).
- At least in one subject, the later student has a strictly greater score than the earlier student, i.e. \( \exists j: s_i[j] < s_{i+1}[j] \).
Formally, given a list of three students with scores, we first sort the list in non-decreasing order (lexicographically) and then check if for each \(i=1,2\) the conditions \( s_i[j] \le s_{i+1}[j]\) for all \(j\) and \( \exists j \) such that \( s_i[j] < s_{i+1}[j] \) hold. If they do, output yes
; otherwise, output no
.
For each test group, output the result on a separate line.
inputFormat
The input is read from standard input. The first line contains a single integer \( T \) denoting the number of groups. For each group, the next three lines contain three space-separated integers each, representing the scores of a student.
For example:
2 50 60 70 60 70 80 70 80 90 90 80 70 80 90 60 70 60 50
outputFormat
For each group, print a single line with either yes
or no
based on whether the students can be arranged in the required order.
For the sample input above, the output would be:
yes no## sample
2
50 60 70
60 70 80
70 80 90
90 80 70
80 90 60
70 60 50
yes
no
</p>