Submission #445891

# Submission time Handle Problem Language Result Execution time Memory
445891 2021-07-20T05:22:55 Z Jasiekstrz Crtanje (COCI20_crtanje) C++17
50 / 50
1 ms 460 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=1000;
int tab[N+10];
char ans[N+10][2*N+10];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		char c;
		cin>>c;
		if(c=='+')
			tab[i]=tab[i-1]+1;
		if(c=='-')
			tab[i]=tab[i-1]-1;
		if(c=='=')
			tab[i]=tab[i-1];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=2*N;j++)
			ans[i][j]='.';
	}
	for(int i=1,j=N;i<=n;i++)
	{
		if(tab[i]<tab[i-1])
		{
			j--;
			ans[i][j]='\\';
		}
		if(tab[i]==tab[i-1])
			ans[i][j]='_';
		if(tab[i]>tab[i-1])
		{
			ans[i][j]='/';
			j++;
		}
	}
	for(int j=2*N;j>=1;j--)
	{
		bool ok=false;
		for(int i=1;i<=n;i++)
			ok=(ok || ans[i][j]!='.');
		if(!ok)
			continue;
		for(int i=1;i<=n;i++)
			cout<<ans[i][j];
		cout<<"\n";
	}
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct