Cod sursa(job #1644929)

Utilizator alexandra_udristoiuUdristoiu Alexandra Maria alexandra_udristoiu Data 10 martie 2016 10:18:46
Problema Oras Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.18 kb
#include<fstream>
using namespace std;
int n, i, j, x;
int a[205][205];
int ai[4][4] = {
    {0, 0, 0, 0},
    {0, 0, 1, 0},
    {0, 0, 0, 1},
    {0, 1, 0, 0}
};
int ap[7][7] = {
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 1},
    {0, 1, 0, 0, 0, 0, 1},
    {0, 1, 1, 0, 0, 1, 0},
    {0, 1, 1, 1, 0, 0, 0},
    {0, 0, 1, 0, 1, 0, 0},
    {0, 0, 0, 1, 1, 1, 0}
};
ifstream fin("oras.in");
ofstream fout("oras.out");
int main(){
    fin>> n;
    if(n == 4){
        fout<<"-1\n";
        return 0;
    }
    if(n % 2 == 1){
        for(i = 1; i <= 3; i++){
            for(j = 1; j <= 3; j++){
                a[i][j] = ai[i][j];
            }
        }
        x = 5;
    }
    else{
        for(i = 1; i <= 6; i++){
            for(j = 1; j <= 6; j++){
                a[i][j] = ap[i][j];
            }
        }
        x = 8;
    }
    for(i = x; i <= n; i+= 2){
        a[i - 1][i] = 1;
        for(j = 1; j < i - 1; j++){
            a[j][i - 1] = 1;
            a[i][j] = 1;
        }
    }
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            fout<< a[i][j];
        }
        fout<<"\n";
    }
    return 0;
}