답안 #677246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677246 2023-01-02T16:13:24 Z Mariabf Crtanje (COCI20_crtanje) C++17
50 / 50
1 ms 296 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<char>nums(n);
    int maxim=0;
    int minim=0;
    int suma=0;
    vector<vector<char>>g;
    bool haveto=false;
    for(int i=0; i<n; i++){
        cin>>nums[i];
        if(nums[i]=='+')suma++;
        else if(nums[i]=='-'){
            suma--;
            if(i==0)maxim--;}
        if(haveto){
            if(nums[i]=='-'){
                maxim--;
                haveto=false;
            }haveto=false;
        }
        if(suma>maxim){
            maxim++;
            haveto=true;
        }
        minim=min(suma, minim);
    }if(haveto)maxim--;
    g.resize(n, vector<char>(maxim-minim+1, '.'));
    suma=0;
    for(int i=0; i<n; i++){
        if(nums[i]=='+'){
            g[i][maxim-suma]='/';
            suma++;
        }
        else if(nums[i]=='-'){
            suma--;
            g[i][maxim-suma]=char(92);

        }else{
            g[i][maxim-suma]='_';
        }
    }
    for(int i=0; i<maxim-minim+1; i++){
        for(int j=0; j<n; j++){
            cout<<g[j][i];
        }cout<<'\n';

    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct