Submission #1177049

#TimeUsernameProblemLanguageResultExecution timeMemory
1177049fritlCrtanje (COCI20_crtanje)C++20
Compilation error
0 ms0 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;
    vector<vector<char>> ans(row, vector<char>(n, '.'));
    ll i = mx - 1, 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++) {
        for (ll j = 0; j < n; j++) cout << ans[i][j];
        cout << endl;
    }
}

int main() {
    ll t = 1;
    while(t--) _();
}

Compilation message (stderr)

crtanje.cpp: In function 'void _()':
crtanje.cpp:16:20: error: redeclaration of 'long long int h'
   16 |     ll i = mx - 1, h = 0;
      |                    ^
crtanje.cpp:9:24: note: 'long long int h' previously declared here
    9 |     ll mn = 0, mx = 0, h = 0;
      |                        ^