Submission #677246

#TimeUsernameProblemLanguageResultExecution timeMemory
677246MariabfCrtanje (COCI20_crtanje)C++17
50 / 50
1 ms296 KiB
#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 timeMemoryGrader output
Fetching results...