# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
741700 | lalig777 | Crtanje (COCI20_crtanje) | C++14 | 1 ms | 300 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |