Cod sursa(job #2523471)

Utilizator flaviu_2001Craciun Ioan-Flaviu flaviu_2001 Data 14 ianuarie 2020 10:36:34
Problema Lacate Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.88 kb
#include <bits/stdc++.h>
#define ff first
#define ss second

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

const string file = "lacate";
const ll INF = 9223372036854775807ll;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, inf = 2147483647;

int n;
vector< vector<int > > v;

int main()
{
    ifstream fin (file+".in");
    ofstream fout (file+".out");
    fin >> n;
    v.resize(n, vector<int>(n-1));
    int p = 0, last = 1;
    for (int i = n-1; i >= 1; --i){
        for (int j = 0; j < i; ++j){
            v[p][p+j] = last+j;
            v[p+j+1][p] = last+j;
        }
        last = v[p][p+i-1]+1;
        ++p;
    }
    fout << v.back().back() << " " << n-1 << "\n";
    for (auto x : v){
        for (auto y : x)
            fout << y << " ";
        fout << "\n";
    }
    return 0;
}