Submission #489669

# Submission time Handle Problem Language Result Execution time Memory
489669 2021-11-23T18:19:01 Z fuad27 Crtanje (COCI20_crtanje) C++17
50 / 50
1 ms 276 KB
#include<bits/stdc++.h>
using namespace std;
int k(char c) {
	if(c == '/')return 1;
	if(c == '\\')return -1;
	return 0;
}
int main () {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int MAX = 0, MIN = 0, curr = 0;
	for(char i:s) {
		if(i == '+')curr++;
		else if(i == '-')curr--;
		else {
			MAX = max(MAX, curr+1);
		}
		MAX = max(MAX, curr);
		MIN = min(MIN, curr);
	}
	char arr[MAX-MIN][n];
	curr = MAX;
	char c = '.';
	for(int i = 0;i<n;i++) {

		if(s[i] == '+')curr--;
		if(s[i] == '+')c = '/';
		else if(s[i] == '-')c='\\';
		else {c='_';curr--;}
		for(int j = 0;j<MAX-MIN;j++) {
			if(j == curr)arr[j][i] = c;
			else arr[j][i] = '.';
		}
		if(s[i] == '-')curr++;
		else if(s[i] == '=')curr++;
	}
	for(int i = 0;i<MAX-MIN;i++) {
		for(int j = 0;j<n;j++) {
			cout << arr[i][j];
		}
		cout << endl;
	}
	if(MAX-MIN == 0) {
		for(int i = 0;i<n;i++)cout<<'-';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 276 KB Output is correct