Cod sursa(job #844645)

Utilizator a_h1926Heidelbacher Andrei a_h1926 Data 29 decembrie 2012 17:39:23
Problema Oras Scor 95
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.02 kb
#include <cstdio>
#include <cassert>

using namespace std;

const int MaxN = 205;

int NV, G[MaxN][MaxN];

void Solve(int N) {
    if (N == 3) {
        G[1][2] = G[2][3] = G[3][1] = 1;
        return;
    }
    if (N == 6) {
        G[1][2] = G[1][3] = G[1][4] = 1;
        G[2][3] = G[2][4] = G[2][5] = 1;
        G[3][4] = G[3][6] = 1;
        G[4][5] = G[4][6] = 1;
        G[5][1] = G[5][3] = G[5][6] = 1;
        G[6][1] = G[6][2] = 1;
        return;
    }
    Solve(N - 2);
    G[N - 1][N] = 1;
    for (int X = 1; X < N - 1; ++X)
        G[X][N - 1] = G[N][X] = 1;
}

void Read() {
    assert(freopen("oras.in", "r", stdin));
    assert(scanf("%d", &NV) == 1);
}

void Print() {
    assert(freopen("oras.out", "w", stdout));
    if (NV == 4) {
        printf("-1\n");
        return;
    }
    for (int i = 1; i <= NV; ++i, printf("\n"))
        for (int j = 1; j <= NV; ++j)
            printf("%d", G[i][j]);
}

int main() {
    Read();
    Solve(NV);
    Print();
    return 0;
}