# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
379263 | VEGAnn | Crtanje (COCI20_crtanje) | C++14 | 1 ms | 364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |