UVa : 11387 (The 3-Regular Graph)



// http://uva.onlinejudge.org/external/113/11387.html
// Runtime: 0.016s
// Tag: Graph, easy 

#include <cstdio>

int main ()
{
    int n;

    while ( scanf ("%d", &n) && n ) {
        if ( n % 2 || n < 4 ) printf ("Impossible\n");
        else {
            printf ("%d\n", n * 3 / 2);
            for ( int i = 1; i < n; i++ ) printf ("%d %d\n", i, i + 1);
            printf ("%d %d\n", n, 1);

            int tmp = n / 2 + 1;

            for ( int i = 1; i <= n / 2; i++ )
                printf ("%d %d\n", i, tmp++);
        }
    }

    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