답안 #447999

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

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++;
    vector<vector<char>>v(mx-mn+10,vector<char>(n,'.'));

    int x=mx+5,y=0;
    bool as=false,same=true;
    for(int i = 0 ; i < n ; i++) {
        if(s[i] == '=') {
            v[x][y] = '_';
            if(i < n-1 && s[i+1] == '-') {
                x++;
            }
        } else if(s[i] == '+') {
            v[x][y] = '/';
            if(i < n-1 && (s[i+1] == '+' || s[i+1] == '=')) x--;
        } else {
            v[x][y] = '\\';
            if(i < n-1 && s[i+1] == '-') x++;
        }
        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";
    }
}

Compilation message

crtanje.cpp: In function 'int main()':
crtanje.cpp:20:10: warning: unused variable 'as' [-Wunused-variable]
   20 |     bool as=false,same=true;
      |          ^~
crtanje.cpp:20:19: warning: unused variable 'same' [-Wunused-variable]
   20 |     bool as=false,same=true;
      |                   ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct