Source Code
#include <bits/stdc++.h>
using namespace std;
	vector <string> vct;
string fnc(int x){
	string s="";
	for(int i=0;i<x;i++){
		s+='-';
	}
	return s;
}
void f(int l,int r,int z){
	if(l>r){
		return;
	}
	long long mid =ceil((l+r)/2);
	vct[mid]=fnc(z);
	f(mid+1,r,z-1);
	f(l,mid-1,z-1);
}
int main() {
	int l,p;
	cin>>l>>p;
	vct.resize(100000);
	f(0,2<<(p-1),p-1);
	for(int i=0;i<l;i++){
		cout<<fnc(p)<<i<<endl;
		for(int j=0;j<(2<<(p-1));j++){
			if(vct[j]!="")
			cout <<vct[j]<<endl;
		}
	}
	cout<<fnc(p)<<l<<endl;
	
	

	return 0;
}
Copy
Ruler fakher20
GNU G++17
14 ms
4.1 MB
Accepted