#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';
}
}
# |
Verdict |
Execution time |
Memory |
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 |