Source Code
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

void _121(){
    cout<<"-"<<endl;
    cout<<"--"<<endl;
    cout<<"-"<<endl;
}
void nDashes(int n){
    for(int i = 0 ; i<n ; i++)
        cout<<"-";
}

int l,p;
void solve(){
    cin>>l>>p;
    if(p == 1){
        for(int i = 0 ; i<=l ; i++){
            nDashes(p); cout<<i<<endl;
        }
        return;
    }
    else if(p == 2){
        for(int i= 0 ; i<l ; i++){
            nDashes(p); cout<<i<<endl;
            cout<<"-"<<endl;
        }
        nDashes(p); cout<<l<<endl;
        return;
    }
    for(int i = 0 ; i<l ; i++){
        nDashes(p);cout<<i<<endl;
        
        _121();
        for(int pp = 3 ; pp<p ; pp++){
            nDashes(pp);cout<<endl;
            _121();
        }
        for(int pp = p-2 ; pp>=3 ; pp--){
            nDashes(pp);cout<<endl;
            _121();
        }
    }
    nDashes(p);cout<<l<<endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.in","r",stdin);
    #endif


    int tt = 1;
    // cin>>tt;
    while(tt--)
        solve();
}   
Copy
Ruler YouKn0wWho
GNU G++17
3 ms
812 KB
Wrong Answer