#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
vector < pair < int, int > > worth(n + 1, {0, 0});
int maximum = -1e9, minimum = 0;
for (int i = 1; i <= n; ++i) {
char c;
cin >> c;
if (c == '+') {
if (worth[i - 1].second == 1)
worth[i] = make_pair(worth[i - 1].first + 1, 1);
else
worth[i] = make_pair(worth[i - 1].first, 1);
} else if (c == '-') {
if (worth[i - 1].second == 1)
worth[i] = make_pair(worth[i - 1].first, -1);
else worth[i] = make_pair(worth[i - 1].first - 1, -1);
} else {
if (worth[i - 1].second == 1) {
worth[i] = make_pair(worth[i - 1].first + 1, 0);
} else if (worth[i - 1].second == -1) {
worth[i] = make_pair(worth[i - 1].first, 0);
} else {
worth[i] = make_pair(worth[i - 1].first, 0);
}
}
maximum = max(maximum, worth[i].first);
minimum = min(minimum, worth[i].first);
}
for (int i = maximum; i >= minimum; --i) {
for (int j = 1; j <= n; ++j) {
// posición actual = maximum - i
int a = worth[j].second;
if (a == 1) { // +
if (i == worth[j].first)
cout << '/';
else cout << '.';
} else if (a == 0) { // =
if (i == worth[j].first)
cout << '_';
else cout << '.';
} else { // -
if (i == worth[j].first)
cout << '\\';
else cout << '.';
}
}
cout << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |