#include <bits/stdc++.h>
using namespace std;
const int N = 210;
char c[N][N];
string s;
int n;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> s;
int mn = 0, mx = 0, cur = 0;
for (int i = 0; i < n; i++){
if (s[i] == '+'){
cur++;
mx = max(mx, cur);
} else if (s[i] == '-'){
cur--;
mn = min(mn, cur);
}
}
if (mx - mn == 0){
for (int i = 0; i < n; i++)
cout << "_";
return 0;
}
// cout << mx - mn << '\n';
for (int i = 0; i < mx - mn + 1; i++)
for (int j = 0; j < n; j++)
c[i][j] = '.';
cur = 0;
int mim = 100, mix = -100;
for (int i = 0; i < n; i++){
if (s[i] == '+'){
mim = min(mim, mx - cur);
mix = max(mix, mx - cur);
c[mx - cur][i] = '/';
cur++;
} else if (s[i] == '-'){
cur--;
c[mx - cur][i] = '\\';
mim = min(mim, mx - cur);
mix = max(mix, mx - cur);
} else {
c[mx - cur][i] = '_';
mim = min(mim, mx - cur);
mix = max(mix, mx - cur);
}
}
for (int i = 0; i < mix - mim + 1; i++){
for (int j = 0; j < n; j++)
cout << c[mim + i][j];
cout << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |