Cod sursa(job #1344610)

Utilizator george_stelianChichirim George george_stelian Data 16 februarie 2015 20:55:24
Problema Oras Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
#include <cstdio>
#include <cstring>

using namespace std;

char v[210][210];

int main()
{
    freopen("oras.in", "r", stdin);
    freopen("oras.out", "w", stdout);
    int n,i;
    scanf("%d",&n);
    if(n==4)
    {
        printf("-1");
        return 0;
    }
    if(n%2)
    {
        strcpy(v[1]+1,"010");
        strcpy(v[2]+1,"001");
        strcpy(v[3]+1,"100");
        i=5;
    }
    else
    {
        strcpy(v[1]+1,"010101");
        strcpy(v[2]+1,"001011");
        strcpy(v[3]+1,"100010");
        strcpy(v[4]+1,"011010");
        strcpy(v[5]+1,"100001");
        strcpy(v[6]+1,"001100");
        i=8;
    }
    for(;i<=n;i+=2)
    {
        v[i-1][i]='1';
        for(int j=1;j<=i-2;j++) v[j][i-1]=v[i][j]='1';
    }
    for(int i=1;i<=n;i++) printf("%s\n",v[i]+1);
    return 0;
}