UVa: 11942 (Lumberjack Sequencing)



// link: http://uva.onlinejudge.org/external/119/11942.html
// Runtime: 0.009s

#include <cstdio>


using namespace std;

int main ()
{

    int testCases;

    scanf ("%d", &testCases);

    printf ("Lumberjacks:\n");

    while ( testCases-- ) {

        int lumberjack [10 + 2];

        for ( int i = 0; i < 10; i++ ) {
            scanf ("%d", &lumberjack [i]);
        }

        bool isBig = true;

        if (lumberjack [0] > lumberjack [1]) isBig = false;

        bool ordered = true;

        if (isBig) {

            for ( int i = 1; i < 10; i++ ) {
                if (lumberjack [i] < lumberjack [i - 1]) ordered = false;
            }

        } else {

            for ( int i = 1; i < 10; i++ ) {
                if (lumberjack [i] > lumberjack [i - 1]) ordered = false;
            }
        }

        if (ordered)
            printf ("Ordered\n");
        else
            printf ("Unordered\n");

    }

    return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s