Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Archives
Today
Total
관리 메뉴

코딩로그

[백준/BOJ/C++] 4589번 Gnome Sequencing 본문

YJ/C++

[백준/BOJ/C++] 4589번 Gnome Sequencing

Team DAON 2021. 11. 2. 17:34

[문제]

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.

[Source Code]

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;


int main() {
	int test;
	cin >> test;
	bool *arr = new bool[test];

	for(int i = 0; i < test; i++){
		int a, b, c;
		cin >> a >> b >> c;

		if(a < b && b < c)
			arr[i] = true;
		else if( a > b && b > c)
			arr[i] = true;
		else
			arr[i] = false;
	}

	cout << "Gnomes:\n";
	for(int i = 0; i<test; i++){
		if(arr[i] == true)
			cout << "Ordered\n";
		else
			cout << "Unordered\n";
	}
}

[결과 화면]