Cod sursa(job #2039215)

Utilizator cella.florescuCella Florescu cella.florescu Data 14 octombrie 2017 12:49:25
Problema Oras Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.87 kb
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e2;

int mat[MAXN][MAXN];

int main()
{
    int n;
    ifstream fin("oras.in");
    fin >> n;
    fin.close();
    ofstream fout("oras.out");
    if (n != 4) {
      if (n & 1)
        mat[0][1] = mat[1][2] = mat[2][0] = 1;
      else
        mat[0][1] = mat[0][5] = mat[1][2] = mat[1][3] = mat[2][0] = mat[2][5] = mat[3][0] = mat[3][2] = mat[3][4] = mat[4][0] = mat[4][1] = mat[4][2] = mat[5][1] = mat[5][3] = mat[5][4] = 1;
      for (int i = (2 - n % 2) * 3; i < n; i += 2) {
        for (int j = 0; j < i; ++j)
          mat[j][i] = mat[i + 1][j] = 1;
        mat[i][i + 1] = 1;
      }
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j)
          fout << mat[i][j];
        fout << '\n';
      }
    } else
      fout << -1;
    fout.close();
    return 0;
}