Source Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IAMSPEED ios_base::sync_with_stdio(0); cin.tie(0);

const int inf = 2e9;
const ll infll = 1e18;
const int M = 1000000007;
const int N = 2e5;

//3 4
int l, p;
void calc(int at, vector<string> &v){
   if(at == 0) return;
   if(at == 1){
        v.assign(1, "-");
        return;
   }
   calc(at-1, v);
   int n = v.size();
   string s = "";
   for(int i = 0; i < at; ++i) s += '-';
   v.pb(s);
   for(int i = 0; i < n; ++i){
    v.pb(v[i]);
   }
}
int main(){
    IAMSPEED
    cin >> l >> p;
    string s = "";
    for(int i = 0; i < p; ++i){
        s += '-';
    }
    vector<string> cm;
    calc(p-1, cm);
    for(int i = 0; i < l; ++i){
        cout << s << i << '\n';
        for(auto x : cm){
            cout << x << '\n';
        }
    }


    cout << s << l << '\n';

}

Copy
Ruler Hambubger
GNU G++17
3 ms
1.0 MB
Accepted