//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define ONLINE_JUDGE
void solve() {
int n;
cin >> n;
string s;
cin >> s;
int val = 0, mx = 0, mn = 0;
for(char &ch : s) {
if(ch == '+') {
val++;
} else if(ch == '-') {
val--;
}
mx = max(mx, val);
mn = min(mn, val);
}
int yaz = 0;
vector <vector <char>> tablo(mx - mn +1, vector <char> (n, '.'));
val = 0;
for(int i = 0; i < n; i++) {
cerr << i << " " << val << "\n";
char ch = s[i];
if(ch == '+') {
assert(val - mn >= 0);
yaz = max(yaz, val - mn);
tablo[val - mn][i] = '/';
val++;
} else if(ch == '-') {
assert(val - mn >= 0);
val--;
yaz = max(yaz, val - mn);
tablo[val - mn][i] = '\\';
} else {
assert(val - mn >= 0);
yaz = max(yaz, val - mn);
tablo[val - mn][i] = '_';
}
}
for(int i = yaz; i >= 0; i--) {
for(int j = 0; j < n; j++) {
cout << tablo[i][j];
}
cout << "\n";
}
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
for(int i = 1; i <= t; i++) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |