Source Code
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define fast ios::sync_with_stdio(false);cin.tie(0);
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<int, null_type, less<int>,
        rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main(){
	fast
	
	int l,p;
	cin>>l>>p;
	string between = "";
	
	for(int i=2;i<=p;i++){
		string cur = "";
		for(int j=0;j<i-1;j++) cur += "-";
		between = between + cur + "\n" + between;
		}
	for(int i=0;i<=l;i++){
		for(int j=0;j<p;j++) cout<<'-';
		cout<<i<<endl;
		if(i!=l)cout<<between;
		}
	
return 0;
}
Copy
Ruler Bahaa
GNU G++17
3 ms
1.0 MB
Accepted