Source Code
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <iostream>
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define p_b push_back
#define all(c) c.begin(), c.end()
#define mem(array, some_data) memset(array, some_data, sizeof array);
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; //printf("%lld ", ll); to out put long
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tree<int ,null_type,less<int >,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
const double eps = 1e-6;
const int MAXN = 2e5 + 3;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
bool ODD(ll O)
{
    return (O % 2 != 0);
}

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
int dx[] = {1, 0, -1, 0,-1, 1, -1, 1};
int dy[] = {0, 1, 0, -1,-1, 1, 1, -1};

bool is_power_of_2(int x) {
    if(x == 0) return true;
    return (ceil(log2(x)) == floor(log2(x)));
}
/*------ never give up --------*/



void solve(int test_case)
{

    int l, p;
    cin >> l >> p;
    string sub = "-\n--\n-\n";
    string main_part = sub;
    for(int i = 3; i <= p - 2; i++) {
        for(int j = 0; j < i; j++) main_part += "-";
        main_part += "\n";
        main_part += sub;

    }
    string mid = "";
    for(int i = 0; i < p - 1; i++) mid += "-";
    string tmp = main_part;
    reverse(all(tmp));
    main_part= main_part + mid + tmp;
    main_part += "\n";
    if(p == 3) {
        main_part = sub;
    }
    if(p == 2) {
        main_part = "-\n";
    }
    if(p == 1) main_part = "";;
    for(int i = 0; i <= l; i++) {
        string cur = "";
        for(int j = 0; j < p; j++) cur += "-";
        cout << cur << i << "\n";
        if(i < l) cout << main_part;
    }

}
int main()
{

    //ios_base::sync_with_stdio(0); cin.tie(0);
    int n = 1;
    //cin >> n;

    while (n--)
    {

        solve(n);
    }

    return 0;
}
Copy
Ruler OBITO
GNU G++17
3 ms
856 KB
Wrong Answer