제출 #1177318

#제출 시각아이디문제언어결과실행 시간메모리
1177318thesentroCrtanje (COCI20_crtanje)C++20
50 / 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= 1, mini=1, curr=1;
    
    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]=='+')
                    curr++;
                if (s[i-1]=='-' or s[i-1]=='=')
                    curr--;
            }
        }
        maxi= max(maxi, curr);
        mini =min(mini, curr);
    }
    
    ll sz;
    sz = maxi-mini+1;

    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] ='/';
        }
        else{
        if (s[i]=='=')
            v[st][i+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...