Submission #741700

#TimeUsernameProblemLanguageResultExecution timeMemory
741700lalig777Crtanje (COCI20_crtanje)C++14
50 / 50
1 ms300 KiB
#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 timeMemoryGrader output
Fetching results...