Source Code
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<utility>
#include<list>
#include<set>
#include<functional>
#include<assert.h>

using namespace std;
using ll = long long;
using ld = long double;

const int N = (int)2e5 + 5;

using namespace std;

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


void solve() {
  int l, p;
  cin >> l >> p;
  vector<string> dashes(11);
  dashes[1] = "-";
  for(int i = 2; i <= 10; i++){
    dashes[i] = dashes[i - 1] + "-";
  }

  for (int i = 0; i <= l; i++) {
    cout << dashes[p] << i << '\n';
    if (i == l)break;
    int tmp = 3;
    while (tmp < p) {
      cout << dashes[1] << '\n' << dashes[2] << '\n' << dashes[1] << '\n';
      cout << dashes[tmp] << '\n';
      tmp++;
    }
    tmp -= 2;
    while (tmp > 2) {
      cout << dashes[1] << '\n' << dashes[2] << '\n' << dashes[1] << '\n';
      cout << dashes[tmp] << '\n';
      tmp--;
    }
      cout << dashes[1] << '\n' << dashes[2] << '\n' << dashes[1] << '\n';
  }
}


int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _ = 1;
  //cin >> _;

  while (_--) {
    solve();
    cout << '\n';
  }
}
Copy
Ruler iyaad
GNU G++17
3 ms
736 KB
Wrong Answer