답안 #447996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
447996 2021-07-28T12:41:43 Z PiejanVDC Crtanje (COCI20_crtanje) C++17
30 / 50
1 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

/*
*
*   (1) Special case ==> / + _
*
*   (2) Array size fix
*
*
*/

signed main() {
    int n; cin>>n;
    string s; cin>>s;
    int mn=0,mx=0,curr=0;
    bool f=false;
    for(auto z : s) {
        if(z=='+') curr++;
        else if(z=='-') curr--;
        else if(curr == mx) f=true;
        if(curr > mx) f=false;
        mn=min(mn,curr),mx=max(mx,curr);
    }
    if(f) mx++;
    //cout << mx << " " << mn << "\n";
    vector<vector<char>>v(mx-mn+10,vector<char>(n,'.'));

    int x=mx+5,y=0;
    bool as=false,same=true;
    for(auto z : s) {
        ///cout << x << " " << y << "\n";
        if(same) {
            if(z == '+') {
                as=true,same=false;
                v[x][y]='/';
            } else if(z == '-') {
                same=false;
                v[x][y]='\\';
            } else v[x][y]='_';
        } else if(as) {
            if(z == '+') {
                x--;
                v[x][y]='/';
            } else if(z == '-') {
                as=false;
                v[x][y]='\\';
            } else x--,v[x][y]='_',as=false,same=true;
        } else {
            if(z == '+') {
                as=true;
                v[x][y]='/';
            } else if(z == '-') {
                x++,v[x][y]='\\';
            } else v[x][y]='_',same=true;
        }
        y++;
    }

    for(auto z : v) {
        string a="";
        bool print=false;
        for(auto x : z) {
            a+=x;
            if(x!='.') print=true;
        }
        if(print)
            cout << a << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Correct 1 ms 204 KB Output is correct