Submission #881508

#TimeUsernameProblemLanguageResultExecution timeMemory
881508SharkyHomework (CEOI22_homework)C++17
100 / 100
298 ms87992 KiB
#include <bits/stdc++.h> using namespace std; using T = pair<pair<int, int>, int>; T merge(T A, T B, string f) { if (f == "min") return {{min(A.first.first, B.first.first), A.first.second + B.first.second - 1}, A.second + B.second}; return {{A.first.first + B.first.first, max(A.second + B.first.second, A.first.second + B.second)}, A.second + B.second}; } struct item { string f; vector<T> op; } dummy; int32_t main() { string s; cin >> s; stack<item> stk; for (int i = 0; i < s.length(); i++) { if (s[i] == 'm') stk.push(dummy); if (isalpha(s[i])) stk.top().f += s[i]; if (s[i] == '?') stk.top().op.push_back({{1, 1}, 1}); if (s[i] == ')') { assert((int) stk.top().op.size() == 2); T rv = merge(stk.top().op[0], stk.top().op[1], stk.top().f); stk.pop(); if (!stk.empty()) stk.top().op.push_back(rv); else cout << rv.first.second - rv.first.first + 1 << '\n'; } } }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < s.length(); i++) {
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...