ACM (UVa) : 11063


// http://online-judge.uva.es/p/v110/11063.html

#include <cstdio>
#include <map>
using namespace std;

int main ()
{
    int cases = 0;
    int n;
    int a [102];

    while ( scanf ("%d", &n) != EOF ) {

        for ( int i = 0; i < n; i++ )
            scanf ("%d", &a [i]);

        bool flag = true;

        for ( int i = 0; i < n - 1; i++ ) {
            if ( a [i] < 1 || a [i] >= a [i + 1] ) {
                flag = false;
                i = n;
            }
        }

        if ( flag ) {
            map <int, int> m;
            m.clear ();

            for ( int i = 0; i < n; i++ ) {
                for ( int j = i; j < n; j++ ) {
                    if ( m [a[i] + a[j]] == 1 ) {
                        flag = false;
                        i = j = n;
                    }

                    else
                        m [a[i] + a[j]] = 1;
                }
            }

            if ( flag )
                printf ("Case #%d: It is a B2-Sequence.\n\n", ++cases);
            else
                printf ("Case #%d: It is not a B2-Sequence.\n\n", ++cases);


        }

        else
            printf ("Case #%d: It is not a B2-Sequence.\n\n", ++cases);
    }

    return 0;
}
Advertisements

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