# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
374276 | NONAME | Crtanje (COCI20_crtanje) | C++17 | 1 ms | 384 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;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int n, cnt;
string s;
vector <vector <char> > a;
vector <int> all;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
cin >> s;
for (int i = 0; i < n; ++i) {
if (s[i] == '-') {
++cnt;
}
all.push_back(cnt);
if (s[i] == '+') {
--cnt;
}
}
sort(all.begin(), all.end());
all.resize(unique(all.begin(), all.end()) - all.begin());
a.resize((int)(all.size()));
for (int i = 0; i < (int)(all.size()); ++i) {
a[i].assign(n, '.');
}
cnt = 0;
for (int i = 0; i < n; ++i) {
if (s[i] == '-') {
++cnt;
}
int p = lower_bound(all.begin(), all.end(), cnt) - all.begin();
if (s[i] == '+') {
a[p][i] = '/';
} else if (s[i] == '-') {
a[p][i] = '\\';
} else {
a[p][i] = '_';
}
if (s[i] == '+') {
--cnt;
}
}
for (int i = 0; i < (int)(all.size()); ++i, cout << "\n") {
for (int j = 0; j < n; ++j) {
cout << a[i][j];
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |