반응형
SMALL
문제 정보
문제명 - Gnome Sequencing
난이도 - 브론즈 IV
문제 번호 - 4589번
문제 링크
https://www.acmicpc.net/problem/4589
4589번: Gnome Sequencing
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
www.acmicpc.net
문제
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.
예제 입력/출력
예제 입력 예제 출력 3 40 62 77 88 62 77 91 33 18
Gnomes: Ordered Unordered Ordered
알고리즘 분류
● 구현
소스코드
package Lv1_Bronze;
import java.io.*;
import java.util.*;
/**
* @author HanHoon
* @category 구현
* https://www.acmicpc.net/problem/4589
*/
public class BOJ_B4_4589_Gnome_Sequencing {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = null;
StringBuilder str = new StringBuilder();
// N
int N = Integer.parseInt(br.readLine());
str.append("Gnomes:\n");
for (int n = 0; n < N; n++){
boolean ascCheck = true;
boolean descCheck = true;
st = new StringTokenizer(br.readLine());
int num = Integer.parseInt(st.nextToken());
for(int i = 1; i < 3; i++){
int tmp = Integer.parseInt(st.nextToken());
if(num < tmp)
descCheck = false;
else if(num > tmp)
ascCheck = false;
num = tmp;
}
if(ascCheck || descCheck)
str.append("Ordered\n");
else
str.append("Unordered\n");
}
System.out.print(str);
br.close();
}
}
BaekJoon List
BaekJoon List
BOJ Start!! ● [BOJ] 백준 회원가입, 시작하는 법 ● [BOJ] 등급(티어) 및 Solved.AC 적용 ● [BOJ/JAVA] 백준 소스코드 제출 시 유의사항(자바) Bronze ● Bronze V - ● Bronze IV - ● Bronze III -..
han-hoon.tistory.com
기회는 준비된 자에게 찾아온다.
![](https://t1.daumcdn.net/keditor/emoticon/friends1/large/014.gif)
반응형
LIST
'BaekJoon > Bronze' 카테고리의 다른 글
[BOJ/JAVA] 백준 4696 : St. lves (자바) (1) | 2023.07.16 |
---|---|
[BOJ/JAVA] 백준 5341 : Pyramids (자바) (0) | 2023.07.15 |
[BOJ/JAVA] 백준 5339 : 콜센터 (자바) (0) | 2023.07.14 |
[BOJ/JAVA] 백준 4470 : 줄번호 (자바) (0) | 2023.07.14 |
[BOJ/JAVA] 백준 4299 : AFC 윔블던 (자바) (0) | 2023.07.11 |
댓글