Cod sursa(job #1336778)

Utilizator wGEORGEWGeorge Cioti wGEORGEW Data 8 februarie 2015 09:14:42
Problema Oras Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.82 kb
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
 
using namespace std;
 
#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "oras";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif
 
typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;
 
const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int NMAX = 200 + 5;
 
int N;
char sol[NMAX][NMAX];
 
void solve(int N) {
    if(N == 3) {
        strcpy(sol[1] + 1, "010");
        strcpy(sol[2] + 1, "001");
        strcpy(sol[3] + 1, "100");
        return;
    }
 
    if(N == 6) {
        return;
    }
 
    solve(N - 2);
 
    for(int i = 1; i <= N - 2; i++) {
        sol[i][N - 1] = '1';
        sol[N][i] = '1';
    }
 
    sol[N - 1][N] = '1';
}
 
int main() {
#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif
 
    scanf("%d", &N);
 
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= N; j++)
            sol[i][j] = '0';
 
    if(N != 4) {
        solve(N);
        for(int i = 1; i <= N; i++)
            printf("%s\n", sol[i] + 1);
    } else
        printf("-1\n");
 
    return 0;
}