# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1177097 | mdael.ali | Crtanje (COCI20_crtanje) | C++20 | 1 ms | 1344 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll n;
cin>>n;
string s;
cin>>s;
ll cem=0;
ll maks=0,mini=0;
for(ll i=0; i<n; i++)
{
if(s[i]=='+')
{
cem++;
}
if(s[i]=='-')
cem--;
maks=max(maks,cem);
mini=min(mini,cem);
}
maks+=5;
mini+=5;
ll c=5;
ll d=maks-mini;
ll b=maks;
vector<vector<char>>v(1001,vector<char>(1001,'.'));
for(ll i=0; i<n-1; i++)
{
if(s[i]=='+' and s[i+1]=='-')
{
v[c][i]='/';
}
if(s[i]=='+' and s[i+1]!='-')
{
v[c][i]='/';
c--;
}
else if(s[i]=='-' and s[i+1]!='-') {
v[c][i]='\\';
}
else if(s[i]=='-' and s[i+1]=='-')
{
v[c][i]='\\';
c++;
}
else if(s[i]=='=' and s[i+1]=='-')
{
v[c][i]='_';
c++;
}
else if(s[i]=='=' and s[i+1]!='-')
{
v[c][i]='_';
}
}
if(s[n-1]=='-')
{
v[c][n-1]='\\';
}
if(s[n-1]=='+')
{
v[c][n-1]='/';
}
if(s[n-1]=='=')
{
v[c][n-1]='_';
}
int minii = 1e18, maxi = -1e18;
for(int i = 0; i <= 1000; i++)
{
for(int j = 0; j <= 1000; j++)
{
if(v[i][j] != '.')
{
minii = min(minii, i);
maxi = max(maxi, i);
}
}
}
for(ll i=minii; i<=maxi; i++)
{
for(ll j=0; j<n; j++)
{
cout<<v[i][j];
}
cout<<endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |