# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1177103 | theagentbara | Crtanje (COCI20_crtanje) | C++20 | 0 ms | 0 KiB |
#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;
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;
if (s[0] == '+') a[k][0] = '/';
else if (s[0] == '-') a[k][0] = '\';
else a[k][0] = '-';
int l = 1, i = k, j = 0;
while (l < s.size() and isbound(i, j, m, n)) {
if (s[l - 1] == '-') {
if (s[l] == '-') {
if (isbound(i + 1, j + 1, m, n)) {
i++; j++; a[i][j] = '\\';
} else {
ok = 0; break;
}
} else if (s[l] == '+') {
if (isbound(i, j + 1, m, n)) {
j++; a[i][j] = '/';
} else {
ok = 0; break;
}
} else if (s[l] == '=') {
if (isbound(i, j + 1, m, n)) {
j++; a[i][j] = '-';
} else {
ok = 0; break;
}
}
} else if (s[l - 1] == '+') {
if (s[l] == '-') {
if (isbound(i, j + 1, m, n)) {
j++; a[i][j] = '\\';
} else {
ok = 0; break;
}
} else if (s[l] == '+') {
if (isbound(i - 1, j + 1, m, n)) {
i--; j++; a[i][j] = '/';
} else {
ok = 0; break;
}
} else if (s[l] == '=') {
if (isbound(i, j + 1, m, n)) {
j++; a[i][j] = '-';
} else {
ok = 0; break;
}
}
}
else if (s[l - 1] == '=') {
if (s[l] == '-') {
if (isbound(i + 1, j + 1, m, n)) {
i++;j++; a[i][j] = '\\';
} else {
ok = 0; break;
}
} else if (s[l] == '+') {
if (isbound(i - 1, j + 1, m, n)) {
i--;j++; a[i][j] = '/';
} else {
ok = 0; break;
}
} else if (s[l] == '=') {
if (isbound(i, j + 1, m, n)) {
j++; a[i][j] = '-';
} else {
ok = 0; break;
}
}
}
}
//if (ok) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cout << a[i][j];
}
cout << endl;
}
//exit(0);
//}
cout << endl;
}
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(0);
int T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}