照題目要求去做檢查即可。
C++(0.008)
/*******************************************************/
/* UVa 11942 Lumberjack Sequencing */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2012/10/20 */
/*******************************************************/
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int N;
int lumberjacks[12];
bool order;
while( scanf( "%d", &N ) != EOF ){
printf( "Lumberjacks:\n" );
for( int i = 0 ; i < N ; i++ ){
order = true;
for( int j = 0 ; j < 10 ; j++ )
scanf( "%d", &lumberjacks[j] );
for( int j = 2 ; j < 10 ; j++ ){
if( (lumberjacks[j] > lumberjacks[j-1]) ^ (lumberjacks[j-1] > lumberjacks[j-2]) )
order = false;
}
if( order ) printf( "Ordered\n" );
else printf( "Unordered\n" );
}
}
return 0;
}