Source Code
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define answer(x) cout << (x ? "YES\n" : "NO\n")
#define test ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T; cin >> T; while(T--)
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define F first
#define S second
using namespace std;

string v[15]; 

string prnt(ll i)
{
	string s = ""; 
	while(i--) s += "-"; 
	
	return s; 
}


string fn(ll i)
{
	if(v[i] != "1") return v[i]; 
	if(i == 1) return "-\n";

	v[i] = ""; 
	v[i] += fn(i - 1);
	v[i] += prnt(i) + "\n";
	v[i] += fn(i - 1);
	
	
	return v[i];
}

ll n, p;
int main()
{
	for(int i=0 ; i<14 ;i ++) v[i] = "1"; 
	
	
	cin >> n >> p;
	for(int i=0 ;i <n; i++)
	{
		cout << prnt(p) << i << '\n';
		cout << fn(p - 1);
	}
	
	
	cout << prnt(p);
	cout << n;
}
Copy
Ruler MuhammedAlajam
GNU G++17
3 ms
740 KB
Runtime Error