24h購物| | PChome| 登入
2011-12-03 19:17:30| 人氣2,826| 回應0 | 上一篇 | 下一篇

[UVA] 11942 - Lumberjack Sequencing

推薦 0 收藏 0 轉貼0 訂閱站台

 A: Lumberjack Sequencing 

Another tale of lumberjacks?. Let see ...

The lumberjacks are rude, bearded workers, while foremen tend to be bossy and simpleminded. The foremen like to harass the lumberjacks by making them line up in groups of ten, ordered by the length of their beards. The lumberjacks, being of different physical heights, vary their arrangements to confuse the foremen. Therefore, the foremen 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 foremen in determining whether or not the lumberjacks are lined up properly, either from shortest to longest beard or from longest to shortest.

Input 

The input starts with line containing a single integer N, 0 < N < 20, which is the number of groups to process. Following this are N lines, each containing ten distinct positive integers less than 100.

Output 

There is a title line, then one line per set of beard lengths. See the sample output for capitalization and punctuation.

Sample Input 

3 13 25 39 40 55 62 68 77 88 95 88 62 77 20 40 10 99 56 45 36 91 78 61 59 54 49 43 33 26 18

Sample Output 

Lumberjacks: Ordered Unordered Ordered




#include<stdio.h>
#define oo 10000
int main() {
int T;
scanf("%d", &T);
puts("Lumberjacks:");
while(T--) {
int i, st1 = oo, st2 = -oo, f1 = 1, f2 = 1, x;
for(i = 0; i < 10; i++) {
scanf("%d", &x);
if(x < st1) st1 = x;
else f1 = 0;
if(x > st2) st2 = x;
else f2 = 0;
}
puts((f1 != 0 || f2 !=0) ? "Ordered" : "Unordered");
}
return 0;
}

台長: Morris
人氣(2,826) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA] 12068 - Harmonic Mean
此分類上一篇:[UVA] 11854 - Egypt

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文