ACM (TJU) : 2522


#include <iostream>
using namespace std;

int main ()
{
    string input;
    string a [80];

    while ( cin >> input ) {

        if ( input == "*" )
            return 0;

        unsigned int d = 1;
        bool flag = false;

        while ( d < input.length () ) {

            int index = 0;

            for ( unsigned int i = 0; i + d < input.length (); i++ ) {
                string temp;
                temp.push_back (input [i]);
                temp.push_back (input [i + d]);
                //cout << temp << endl;
                a [index++] = temp;
            }

            for ( int i = 0; i < index; i++ ) {
                for ( int j = i + 1; j < index; j++ ) {
                    if ( a [i] == a [j] ) {
                        flag = true;
                        i = j = index;
                    }
                }
            }

            if ( flag ) {
                cout << input << " is NOT surprising." << endl;
                d = input.length ();
            }

            d++;
        }

        if ( !flag )
            cout << input << " is surprising." << endl;
    }

    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