백준: 4589번 Gnome Sequencing (Python3)
Gnome Sequencing 성공다국어
1 초 | 128 MB | 554 | 395 | 365 | 71.709% |
문제
In the book All Creatures of Mythology, gnomes are kind, bearded creatures, while goblins tend to be bossy and simple-minded. The goblins like to harass the gnomes by making them line up in groups of three, ordered by the length of their beards. The gnomes, being of different physical heights, vary their arrangements to confuse the goblins. Therefore, the goblins must actually measure the beards in centimeters to see if everyone is lined up in order.
Your task is to write a program to assist the goblins in determining whether or not the gnomes are lined up properly, either from shortest to longest beard or from longest to shortest.
입력
The input starts with line containing a single integer N, 0 < N < 30, which is the number of groups to process. Following this are N lines, each containing three distinct positive integers less than 100.
출력
There is a title line, then one line per set of beard lengths. See the sample output for capitalization and punctuation.
예제 입력 1
3
40 62 77
88 62 77
91 33 18
예제 출력 1
Gnomes:
Ordered
Unordered
Ordered
답안
1
2
3
4
5
6
7
8
9
10
11
|
num = int(input())
print("Gnomes:")
for i in range(num):
a, b, c = map(int, input().split())
lst= []; lst.append(a); lst.append(b); lst.append(c)
if sorted(lst, reverse=True)==lst or sorted(lst, reverse=False)==lst:
print("Ordered")
else:
print("Unordered")
|
cs |
'공부 > 코딩테스트' 카테고리의 다른 글
백준: 5532번 방학 숙제 (Python3) (0) | 2022.08.02 |
---|---|
백준: 4966번 St. Ives (Python3) (0) | 2022.08.02 |
백준: 4299번 AFC 윔블던 (Python3) (0) | 2022.08.02 |
백준: 3046번 R2 (Python3) (0) | 2022.08.02 |
백준: 2845번 파티가 끝나고 난 뒤 (Python3) (0) | 2022.08.02 |
댓글