#include <bits/stdc++.h>
using namespace std;
char grid[1005][1005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
string str;
cin >> n >> str;
int cur = 0, mx = INT_MIN, mn = INT_MAX;
for(int i = 0; i < n; i++)
{
if(str[i] == '+')
{
grid[cur + n][i] = '/';
mn = min(mn, cur + n);
mx = max(mx, cur + n);
cur++;
}
else if(str[i] == '-')
{
cur--;
grid[cur + n][i] = '\\';
mn = min(mn, cur + n);
mx = max(mx, cur + n);
}
else
{
grid[cur + n][i] = '_';
mn = min(mn, cur + n);
mx = max(mx, cur + n);
}
}
for(int i = mx; i >= mn; i--)
{
for(int j = 0; j < n; j++)
{
if(!grid[i][j])
cout << '.';
else
cout << grid[i][j];
}
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |