Submission #854430

# Submission time Handle Problem Language Result Execution time Memory
854430 2023-09-27T16:15:13 Z vjudge1 Crtanje (COCI20_crtanje) C++17
40 / 50
1 ms 348 KB
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

#define ONLINE_JUDGE
void solve() {
    int n;
    cin >> n;

    string s;
    cin >> s;

    int val = 0, mx = 0, mn = 0;
    for(char &ch : s) {
        if(ch == '+') {
            val++;
        } else if(ch == '-') {
            val--;
        }

        mx = max(mx, val);
        mn = min(mn, val);
    }

    vector <vector <char>> tablo(mx - mn +1, vector <char> (n, '.'));
    val = 0;
    for(int i = 0; i < n; i++) {
        cerr << i << " " << val << "\n";
        char ch = s[i];
        if(ch == '+') {
            assert(val - mn >= 0);
            tablo[val - mn][i] = '/';
            val++;
        } else if(ch == '-') {
            assert(val - mn >= 0);
            val--;
            tablo[val - mn][i] = '\\';
        } else {
            assert(val - mn >= 0);
            tablo[val - mn][i] = '_';
        }
    }

    for(int i = mx - mn -1; i >= 0; i--) {
        for(int j = 0; j < n; j++) {
            cout << tablo[i][j];
        }
        cout << "\n";
    }
    
    return;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen(".in", "r", stdin);
        freopen(".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; //cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Correct 1 ms 348 KB Output is correct