Cod sursa(job #2664667)

Utilizator Xutzu358Ignat Alex Xutzu358 Data 29 octombrie 2020 08:36:52
Problema Dame Scor 60
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <bits/stdc++.h>
using namespace std;

ifstream f("dame.in");
ofstream g("dame.out");

bool colon[1005];
bool mat[1005][1005];
int dame;
int n;

int main()
{
    f >> n;
    dame = n;
    int lin = 1;
    int col = 2;
    while (dame!=0) {
        while (col <= n) {
            mat[lin][col]=1;
            colon[col]=1;
            lin++;
            col+=2;
            dame--;
        }
        col = 1;
        while (colon[col]==1) {
            col++;
        }
    }
    if (n>3) {
        g << n <<'\n';
        for (int i=1;i<=n;i++) {
            for (int j=1;j<=n;j++) {
                if (mat[i][j]==1) {
                    g << i << " " << j << '\n';
                }
            }
        }
    }
    else if (n<=2) {
        g << 1 <<'\n' << 1 << " " <<1;
    }
    else {
        g << 2 << '\n' << 1 << " " << 1 << '\n' << 2 << " " << 3;
    }
    return 0;
}