Submission #854442

# Submission time Handle Problem Language Result Execution time Memory
854442 2023-09-27T16:34:46 Z vjudge1 Crtanje (COCI20_crtanje) C++17
50 / 50
1 ms 512 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define lim 100000
using namespace std;
const int mod=1000000007ll;

void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int maxi=0,mini=0,cur=0;
    //cerr<<"what\n";
    for(int i=0;i<n;i++){
        if(s[i]=='+'){
            maxi=max(maxi,cur);
            mini=min(mini,cur);
            cur++;
        }
        else if(s[i]=='-'){
            cur--;
            maxi=max(maxi,cur);
            mini=min(mini,cur);
        }
        else {
            maxi=max(maxi,cur);
            mini=min(mini,cur);
        }
    }
    int N=maxi-mini+1;
    //cerr<<N<<"\n";
    vector<string> ans(2*N+10);
    cur=N;
    for(int i=0;i<n;i++){
        //cerr<<cur<<"\n";
        for(int j=0;j<ans.size();j++){
            if(cur==j){
                if(s[i]=='+')ans[j].pb('/');
                else if(s[i]=='-'){
                    if(0<=j)ans[j].pb('.');
                    ans[j+1].pb('\\');
                    j++;
                }
                else ans[j].pb('_');
            }else if(0<=j){
                ans[j].pb('.');
            }
        }
        if(s[i]=='+')cur--;
        else if(s[i]=='-')cur++;
    }
    string empt(n,'.');
    for(int i=0;i<ans.size();i++){
        if(ans[i]!=empt)cout<<ans[i]<<"\n";
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen("in","r",stdin);
    freopen("out","w",stdout);
#endif
    solve();
}

Compilation message

crtanje.cpp: In function 'void solve()':
crtanje.cpp:41:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int j=0;j<ans.size();j++){
      |                     ~^~~~~~~~~~~
crtanje.cpp:58:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 512 KB Output is correct