# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
754541 | 2023-06-08T02:56:08 Z | drdilyor | Homework (CEOI22_homework) | C++17 | 120 ms | 101000 KB |
#include <bits/stdc++.h> #ifdef ONPC #include "t_debug.cpp" #else #define debug(...) 42 #endif using namespace std; //namespace pbds = __gnu_pbds; using ll = long long; const int inf = 1e9; const ll infl = 1e18; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); mt19937 rng(RANDOM); template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; } template<typename Cont> int sz(const Cont& cont) { return int(cont.size()); } template<typename Func> struct ycom { Func f; template<typename... T> auto operator()(T&&... args) { return f(*this, args...); } }; template<typename Func> ycom(Func) -> ycom<Func>; template<typename T> typename vector<T>::iterator operator+(const vector<T>& x, int i) { return x.begin() + i ;}; const string fileio = ""; constexpr int tests = 0, nmax = 2e5, nlog = __lg(nmax), mod = 1e9+7; int TQ = 0, TMIN = 1, TMAX = 2; struct node { int type; node* l=nullptr; node* r=nullptr; void print() { if (type == TQ) cout << "?"; else { if (type == TMIN) cout << "min("; else cout << "max("; l->print(); cout << ","; r->print(); cout << ")"; } } }; node* parse(string& s, int& i) { if (s[i++] == '?') return new node{TQ}; auto res = new node; if (s[i++] == 'i') { res->type = TMIN; } else res->type = TMAX; i++; assert(s[i++] == '('); res->l = parse(s, i); assert(s[i++] == ','); res->r = parse(s, i); assert(s[i++] == ')'); return res; } int solve() { string s; cin >> s; int i = 0; auto root = parse(s, i); #ifdef ONPC root->print(); #endif int cnt= 0; int t = root->type; while (root) { if (root->type == t) { root = root->l->type == TQ ? root->r : root->l; cnt++; } else break; } cout << cnt << '\n'; return 0; } signed main() { int t = 1; #ifdef ONPC t = 10000; #else if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);} #endif cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit | cin.eofbit); cout << fixed << setprecision(12); if (tests) cin >> t; while (t-- && cin) { if (solve()) break; #ifdef ONPC cout << "____________________" << endl; #endif } return 0; } /* █████ █████ ███ ████ ▒▒███ ▒▒███ ▒▒▒ ▒▒███ ███████ ████████ ███████ ████ ▒███ █████ ████ ██████ ████████ ███▒▒███ ▒▒███▒▒███ ███▒▒███ ▒▒███ ▒███ ▒▒███ ▒███ ███▒▒███▒▒███▒▒███ ▒███ ▒███ ▒███ ▒▒▒ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒▒▒ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒▒████████ █████ ▒▒████████ █████ █████ ▒▒███████ ▒▒██████ █████ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒███ ▒▒▒▒▒▒ ▒▒▒▒▒ ███ ▒███ ▒▒██████ ▒▒▒▒▒▒ */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 120 ms | 101000 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |