Submission #513020

#TimeUsernameProblemLanguageResultExecution timeMemory
513020KoDCrtanje (COCI20_crtanje)C++17
50 / 50
1 ms332 KiB
#include <bits/stdc++.h> using std::vector; using std::array; using std::pair; using std::tuple; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int N; std::cin >> N; vector<char> S(N); for (auto& x : S) { std::cin >> x; } int min = 1000, max = -1000, cur = 0; for (const char c : S) { if (c == '-') { cur -= 1; } max = std::max(max, cur); min = std::min(min, cur); if (c == '+') { cur += 1; } } vector ans(max - min + 1, vector<char>(N, '.')); cur = 0; for (int i = 0; i < N; ++i) { if (S[i] == '+') { ans[cur - min][i] = '/'; cur += 1; } else if (S[i] == '-') { cur -= 1; ans[cur - min][i] = '\\'; } else { ans[cur - min][i] = '_'; } } std::reverse(ans.begin(), ans.end()); for (const auto& v : ans) { for (int i = 0; i < N; ++i) { std::cout << v[i]; } std::cout << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...