Submission #496100

# Submission time Handle Problem Language Result Execution time Memory
496100 2021-12-20T16:36:48 Z AlperenT Crtanje (COCI20_crtanje) C++17
40 / 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 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 1 ms 204 KB Output is correct
4 Incorrect 1 ms 312 KB Output isn't correct
5 Correct 1 ms 304 KB Output is correct