Cod sursa(job #2274779)

Utilizator laurageorgescuLaura Georgescu laurageorgescu Data 2 noiembrie 2018 14:53:34
Problema Lacate Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin ("lacate.in"); ofstream fout ("lacate.out");

const int nmax = 256;

int v[nmax + 1][nmax + 1];

int main () {
    int n;
    fin >> n;
    fout << n * (n - 1) / 2 << " " << n - 1 << "\n";

    int cnt = 0;
    for (int i = n; i > 1; -- i) {
        for (int j = 1; j < i; ++ j) {
            v[j][++v[j][0]] = ++ cnt;
            v[i][++v[i][0]] = cnt;
        }
    }

    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j < n; ++ j)
            fout << v[i][j] << " ";
        fout << "\n";
    }

    fin.close();
    fout.close();
    return 0;
}