# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494912 | kappa | Crtanje (COCI20_crtanje) | C++14 | 1 ms | 304 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 <bits/stdc++.h>
using namespace std;
int n, up = 99, down = 99, curr = 99;
char d[105], matrix[205][105];
int main(){
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> d[i];
}
memset(matrix, '.', sizeof(matrix));
switch (d[0])
{
case '+':
matrix[curr][0] = '/';
curr--;
break;
case '-':
matrix[curr][0] = '\\';
curr++;
break;
default:
matrix[curr][0] = '_';
break;
}
for (int i = 1; i < n; i++)
{
switch (d[i])
{
case '+':
if(d[i - 1] == '+'){
matrix[curr][i] = '/';
up = min(up, curr);
curr--;
}else if(d[i - 1] == '-'){
matrix[curr - 1][i] = '/';
up = min(up, curr);
curr -= 2;
}else{
matrix[curr][i] = '/';
up = min(up, curr);
curr--;
}
break;
case '-':
if(d[i - 1] == '-'){
matrix[curr][i] = '\\';
down = max(down, curr);
curr++;
}else if(d[i - 1] == '+'){
matrix[curr + 1][i] = '\\';
down = max(down, curr);
curr += 2;
}else{
matrix[curr + 1][i] = '\\';
down = max(down, curr);
curr += 2;
}
break;
default:
if(d[i - 1] == '-'){
curr--;
matrix[curr][i] = '_';
}else if(d[i - 1] == '+'){
//curr++;
matrix[curr][i] = '_';
up = min(up, curr);
}else{
matrix[curr][i] = '_';
}
break;
}
}
for (int i = up; i <= down; i++)
{
for (int j = 0; j < n; j++)
{
cout << matrix[i][j];
}
cout << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |