Cod sursa(job #26676)

Utilizator magicMaria Ionescu magic Data 5 martie 2007 20:20:52
Problema Oras Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include<iostream>
#include<fstream>

#define inputfile "oras.in"
#define outpufile "oras.out"

using namespace std;

const int NMAX = 201;

void solve(int a[NMAX][NMAX], int n) {
  int i = 1, j = 2;
  while (i<=n-2) {
    a[i][j] = 1;
    for (int k = j+1; k<=n; k++) 
      a[j][k] = a[k][i] = 1;
    i += 2;
    j += 2;
  }
}

int main() {
  int n;
  ifstream from(inputfile);
  from>>n;
  from.close();
  
  int a[NMAX][NMAX];
  ofstream to(outpufile);
  if (n % 2 == 0) to<<-1;
  else {
    solve(a,n);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++)
	to<<a[i][j];
      to<<'\n';
    }
  }
  to.close();
}