11942 Lumberjack Sequencing

Problem link: 11942 – Lumberjack Sequencing

 

11942 – Lumberjack Sequencing

Another tale of lumberjacks?. Let see . . .
      The lumberjacks are rude, bearded workers, while foremen tend to be bossy and simple-minded. 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 centimetres 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

Code:

#include<cstdio>

using namespace std;

int main()
{

	int n;
	
	scanf("%d",&n);
	printf("Lumberjacks:\n");
	for(int i=1;i<=n;i++){
		
		
		
		int x;
		x=10;
		int arr[x];
		for(int j=0;j<x;j++)
			scanf("%d",&arr[j]);
			
		int c=0;
		
		int b=1,g=0;
		
		if(x==1){
			printf("Ordered\n");
			g=1;
		}
		else{
			ho:
			if(arr[b]<arr[b-1]){
		
				for(int j=1;j<x;j++){
                                     if(arr[j]>arr[j-1]){
						c=1;
						break;
						}
					
					}
				if(c==1)
					printf("Unordered\n");
				}
			else if(arr[b]>arr[b-1]){
				
				for(int j=1;j<x;j++){
					
					if(arr[j]<arr[j-1]){
						c=1;
						break;
						}
					
					}
				if(c==1)
					printf("Unordered\n");
				}
			else{
				b++;
				goto ho;
				
				}
				
				
				}
			if(c==0 && g==0)
				printf("Ordered\n");
			
		}

	return 0;	
}

Advertisements