Submission #741700

# Submission time Handle Problem Language Result Execution time Memory
741700 2023-05-14T15:13:23 Z lalig777 Crtanje (COCI20_crtanje) C++14
50 / 50
1 ms 300 KB
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int n;
    cin>>n;
    string s="";
    char c;
    int maxi=0, mini=0, total=0;
    cin>>c;
    if (c=='+') s+='/';
    else if (c=='-') s+='\\';
    else s+='_';
    for (int i=1; i<n; i++){
        cin>>c;
        if (c=='+'){
            s+='/';
            if (s[i-1]=='/') total++;
        }else if (c=='-'){
            s+='\\';
            if (s[i-1]=='\\' or s[i-1]=='_') total--;
        }else{
            s+='_';
            if (s[i-1]=='/') total++;
        }if (total>maxi) maxi=total;
        if (total<mini) mini=total;
    }int tabl=maxi-mini+1;
    vector<vector<char>>graf(tabl, vector<char>(n, '.'));
    int j=maxi;
    graf[j][0]=s[0];
    for (int i=1; i<n; i++){
        if (s[i]=='/'){
            if (s[i-1]=='/'){
                graf[j-1][i]='/';
                j--;
            }else graf[j][i]='/';
        }else if (s[i]=='\\'){
            if (s[i-1]=='\\' or s[i-1]=='_'){
                graf[j+1][i]='\\';
                j++;
            }else graf[j][i]='\\';
        }else{
            if (s[i-1]=='/'){
                graf[j-1][i]='_';
                j--;
            }else graf[j][i]='_';
        }
    }for (int j=0; j<tabl; j++){
        for (int i=0; i<n; i++) cout<<graf[j][i];
        cout<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 224 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct