#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
int mini = 0, maxi=-1, cur = 0;
for(int i=0; i<n; i++){
if(s[i] == '-') cur--;
mini = min(cur,mini);
maxi = max(cur,maxi);
if(s[i] == '+') cur++;
}
vector<string> ans(maxi-mini+1, string(n, '.'));
cur = 0;
for(int i=0; i<n; i++) {
if(s[i] == '-') cur--;
char c = '_';
if(s[i] == '+') c = '/';
else if(s[i] == '-') c = '\\';
// cout << c << endl;
// cout << cur - mini << endl;
// cout << ans.size() << endl;
// cout << maxi - mini + 1 << endl;
// cout << maxi << ' ' << mini << endl;
ans[cur - mini][i] = c;
if(s[i] == '+') cur++;
}
for(int i=ans.size()-1; i>=0; i--) cout<<ans[i]<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
500 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |