Submission #1180551

#TimeUsernameProblemLanguageResultExecution timeMemory
1180551okahak71Crtanje (COCI20_crtanje)C++20
50 / 50
1 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

void _() {
    ll n; cin >> n;
    string s; cin >> s;
    ll mn = 0, mx = 0, h = 0;
    for (char c : s) {
        h += (c == '+'); h -= (c == '-');
        mn = min(mn, h); mx = max(mx, h);
    }
    ll row = mx - mn + 1;
    vector<vector<char>> ans(row, vector<char>(n, '.'));
    ll i = max(mx, 0LL); h = 0;
    for (ll j = 0; j < n; j++) {
        if (s[j] == '+') {ans[i][j] = '/'; h++; i--;}
        else if (s[j] == '-') { h--; i++; ans[i][j] = '\\'; }
        else ans[i][j] = '_';
    }
    for (ll i = 0; i < row; i++) {
        bool ok = 1;
        for(ll j = 0; j < n; j++){
          ok &= (ans[i][j] == '.');
        }
        if(ok) continue;
        for (ll j = 0; j < n; j++) 
        {
            //if(j==n-1 && ans[i][j]=='_') cout << ans[i - 1][j];
            cout << ans[i][j];
        }
        cout << endl;
    }
}

int main() {
    ll t = 1; //cin >> t;
    while(t--) _();
}
#Verdict Execution timeMemoryGrader output
Fetching results...