Submission #854571

# Submission time Handle Problem Language Result Execution time Memory
854571 2023-09-28T05:34:51 Z dosts Crtanje (COCI20_crtanje) C++17
50 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define pb push_back
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
const int N = 2e5+1;

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int mini = 0;
	int maxi = 0;
	int cur = 0;
	for (int i=0;i<n;i++) {
		if (s[i] == '+') cur++;
		else if (s[i] == '-') cur--;
		maxi = max(maxi,cur);
		mini = min(mini,cur);
	}	
	int m = n;
	n = maxi-mini;
	vector<vector<char>> grid(n+5,vector<char>(m+5,'.'));
	cur = n-(1-mini)+1;
	for (int i=0;i<m;i++) {
		if (s[i] == '+') {
			grid[cur][i+1] = '/';
			cur--;
		}
		else if (s[i] == '-') {			
			cur++;
			grid[cur][i+1] = '\\';
		}
		else {
			grid[cur][i+1] = '_';
		}
	}
	for (int i=0;i<=n+1;i++) {
		int fl = 0;
		for (int j=1;j<=m;j++) if (grid[i][j] != '.') fl = 1;
		if (fl) {
		for (int j=1;j<=m;j++) cout << grid[i][j];
		cout << endl;
	}
	}
}     
                                
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct