Submission #496101

# Submission time Handle Problem Language Result Execution time Memory
496101 2021-12-20T16:40:23 Z AlperenT Crtanje (COCI20_crtanje) C++17
50 / 50
1 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 100 + 5;

int n, arr[N], mn, mx;

vector<char> rows[N];

string str;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    cin >> n;

    cin >> str;

    str = '$' + str;

    for(int i = 1; i <= n; i++){
        arr[i] = arr[i - 1];
        if(str[i] == '+') arr[i]++;
        else if(str[i] == '-') arr[i]--;
    }

    mn = *min_element(arr, arr + n + 1), mx = *max_element(arr, arr + n + 1);

    for(int i = 1; i <= n; i++) arr[i] += abs(mn);

    mx += abs(mn), mn += abs(mn);

    for(int i = 1; i <= n; i++) if(arr[i] == mx && (str[i] == '-' || str[i] == '=')) mx++;

    for(int col = 1; col <= n; col++){
        if(str[col] == '+'){
            for(int row = mn + 1; row <= mx; row++){
                if(row == arr[col]) rows[row].push_back('/');
                else rows[row].push_back('.');
            }
        }
        else if(str[col] == '-'){
            for(int row = mn + 1; row <= mx; row++){
                if(row == arr[col] + 1) rows[row].push_back('\\');
                else rows[row].push_back('.');
            }
        }
        else if(str[col] == '='){
            for(int row = mn + 1; row <= mx; row++){
                if(row == arr[col] + 1) rows[row].push_back('_');
                else rows[row].push_back('.');
            }
        }
    }

    for(int i = mx; i >= mn + 1; i--){
        for(auto j : rows[i]) cout << j;
        cout << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct