Submission #1177056

#TimeUsernameProblemLanguageResultExecution timeMemory
1177056fritlCrtanje (COCI20_crtanje)C++20
30 / 50
1 ms328 KiB
/*
 _____ _          ____             _             
|_   _| |__   ___/ ___|  ___ _ __ | |_ _ __ ___  
  | | | '_ \ / _ \___ \ / _ \ '_ \| __| '__/ _ \ 
  | | | | | |  __/___) |  __/ | | | |_| | | (_) |
  |_| |_| |_|\___|____/ \___|_| |_|\__|_|  \___/ 
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
void solve()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll maxi= 0, mini=0, curr=0;
    for (int i=0 ; i<s.size() ; i++)
    {
        if (s[i]=='+')
        {
            curr++;
        }
        if (s[i]=='-')
            curr--;
        maxi= max(maxi, curr);
        mini =min(mini, curr);
    }
    ll sz;
    if (maxi==mini and maxi==0)
    {
        sz = 1;
    }
    else
        sz = maxi-mini;
        
    string emimem = "/_";
    vector<vector<char>>v(sz+1, vector<char>(n+1, '.'));
    ll st = maxi;
    if (st==0)
        st = 1;
    // cout<<sz<<endl<<endl;
    for (int i=0 ; i<s.size(); i++)
    {

        if (i!=0)
        {
            if (not((s[i-1]=='+' and s[i]=='-') or (s[i-1]=='-' and s[i]=='+') or(s[i-1]=='-' and s[i]=='=') or
            (s[i-1]=='=' and s[i]=='=')
            or (s[i-1]=='=' and s[i]=='+')))
            {
                if (s[i-1]=='+')
                    st--;
                if (s[i-1]=='-' or s[i-1]=='=')
                    st++;
            }
        }
        if (s[i]=='+')
        {
            v[st][i+1] = emimem[0];
        }
        else{
        if (s[i]=='=')
            v[st][i+1] = emimem[1];
        else
        {
            v[st][i+1] = '\\';
        }
        }
        

        // cout<<v[st][i+1]<<" "<<st<<" "<<i+1<<" "<<s[i]<<endl;
    }
    for (int i=1 ; i<=sz ;i++)
    {
        for (int j=1 ; j<=n ;j++)
            cout<<v[i][j];
        cout<<endl;
        
    }
}
int main()
{
    ll tt=1;
    
    while (tt--)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...