답안 #445890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445890 2021-07-20T05:21:59 Z Jasiekstrz Crtanje (COCI20_crtanje) C++17
40 / 50
1 ms 332 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=100;
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;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Incorrect 1 ms 332 KB Output isn't correct