Cod sursa(job #1898373)

Utilizator marcdariaDaria Marc marcdaria Data 1 martie 2017 23:11:26
Problema Oras Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    ifstream fin("oras.in");
    ofstream fout("oras.out");

    int N,G[205][205];
    fin>>N;
    if(N==4) fout<<-1<<'\n';
    else
    {
        int wat;
        if(N%2) wat=2;
        else wat=3;

        for(int i=1;i<N;++i)
            for(int j=i+1;j<=N;++j)
            G[i][j]=1;

        for(int i=1;i<=N;++i)
            for(int j=i-wat;j>0;j-=2)
            G[i][j]=1,G[j][i]=0;

        if(!N%2) G[3][N]=1,G[N][3]=0;

        for(int i=1;i<=N;++i)
        {for(int j=1;j<=N;++j)
            fout<<G[i][j];
            fout<<'\n';
        }
    }

    return 0;
}