Submission #677242

# Submission time Handle Problem Language Result Execution time Memory
677242 2023-01-02T16:11:46 Z PRC141 Crtanje (COCI20_crtanje) C++14
50 / 50
1 ms 212 KB
#include<bits/stdc++.h>
using namespace std;

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	int n, mx = 0, mn = 0, cur = 0;
    string s;
	cin >> n >> s;

	for(char x: s) {
		if (x == '+') {
            cur++;
        } else if (x == '-'){
            cur--;
        } else {
			mx = max(mx, cur+1);
		}
		mx = max(mx, cur);
		mn = min(mn, cur);
	}
    
	char a[mx-mn][n], y = '.';
	cur = mx;
    
	for(int i = 0;i<n;i++) {
		if (s[i] == '+') {
            cur--;
        } if (s[i] == '+') {
            y = '/';
        } else if (s[i] == '-'){
            y='\\';
        } else {
            y='_';
            cur--;
        }
		for(int j = 0;j < mx-mn;j++) {
			if (j == cur) {
                a[j][i] = y;
            } else {
                a[j][i] = '.';
            }
		}
		if (s[i] == '-') {
            cur++;
        } else if (s[i] == '=') { 
            cur++;
        }
	}
    
	for(int i = 0;i < mx-mn;i++) {
		for(int j = 0; j< n;j++) {
			cout << a[i][j];
		}
		cout << endl;
	}
    
	if (mx-mn == 0) {
		for(int i = 0;i<n;i++){
            cout<<'-';
        }
	}
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct