#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
#define all(v) v.begin(), v.end()
const long long sz = 2e5 + 5;
const long long inf = 1e18;
const long long mod = 1e9 + 9;
bool isbound(int i, int j, int m, int n) {
return i >= 0 and j >= 0 and i < m and j < n;
}
void solve() {
int n;
cin >> n;
string s;
cin >> s;
int m = 0, mx = 0, mn = inf, cur = 0;
for (int i = 0; i < n; i++) {
cur += (s[i] == '+');
cur -= (s[i] == '-');
mx = max(mx, cur); mn = min(mn, cur);
}
m = mx - mn + 1;
for (int k = 0; k < m; k++) {
char a[m][n];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
a[i][j] = '.';
}
}
bool ok = 1;
int i = k;
for (int j = 0; j < n; j++) {
if (!isbound(i, j, m, n)) {
ok = 0;
break;
}
if (s[j] == '+') {
a[i][j] = '/';
i--;
} else if (s[j] == '-') {
i++;
a[i][j] = '\\';
} else {
a[i][j] = '_';
}
}
if (ok) {
for (int i = 0; i < m; i++) {
if (count(a[i], a[i] + n, '.') == n) continue;
for (int j = 0; j < n; j++) {
cout << a[i][j];
}
cout << endl;
}
return;
}
}
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(0);
int T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |