Submission #374276

#TimeUsernameProblemLanguageResultExecution timeMemory
374276NONAMECrtanje (COCI20_crtanje)C++17
50 / 50
1 ms384 KiB
#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 timeMemoryGrader output
Fetching results...