Submission #1177116

#TimeUsernameProblemLanguageResultExecution timeMemory
1177116fritlCrtanje (COCI20_crtanje)C++20
Compilation error
0 ms0 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=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= max(1, 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();
    }
}

Compilation message (stderr)

crtanje.cpp: In function 'void solve()':
crtanje.cpp:41:12: error: no matching function for call to 'max(int, long long int)'
   41 |     sz= max(1, maxi-mini);
      |         ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from crtanje.cpp:8:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
crtanje.cpp:41:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   41 |     sz= max(1, maxi-mini);
      |         ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from crtanje.cpp:8:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
crtanje.cpp:41:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   41 |     sz= max(1, maxi-mini);
      |         ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from crtanje.cpp:8:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
crtanje.cpp:41:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   41 |     sz= max(1, maxi-mini);
      |         ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from crtanje.cpp:8:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
crtanje.cpp:41:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   41 |     sz= max(1, maxi-mini);
      |         ~~~^~~~~~~~~~~~~~