Submission #379263

#TimeUsernameProblemLanguageResultExecution timeMemory
379263VEGAnnCrtanje (COCI20_crtanje)C++14
50 / 50
1 ms364 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...