Submission #679877

#TimeUsernameProblemLanguageResultExecution timeMemory
679877dooompyHomework (CEOI22_homework)C++17
100 / 100
400 ms190076 KiB
#include "bits/stdc++.h" using namespace std; void abc() {cout << endl;} template <typename T, typename ...U> void abc(T a, U ...b) { cout << a << ' ', abc(b...); } template <typename T> void printv(T l, T r) { while (l != r) cout << *l << " \n"[++l == r]; } template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) { return o >> a.first >> a.second; } template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) { return o << '(' << a.first << ", " << a.second << ')'; } template <typename T> ostream& operator << (ostream& o, vector<T> a) { bool is = false; for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;} return o << '}'; } #ifdef local #define test(args...) abc("[" + string(#args) + "]", args) #else #define test(args...) void(0) #endif using ll = long long; struct state { int l, r, ct; }; string s; vector <int> v; map <int, int> mp; state recurse(int l, int r) { if (l == r) { return {1, 1, 1}; } int com = mp[l + 3]; state a = recurse(l + 4, com - 1); state b = recurse(com + 1, r - 1); bool t = (s[ l + 2] == 'x'); if (t) { return {a.l + b.l, max({a.r + b.ct, b.r, a.r, b.r + a.ct}), a.ct + b.ct}; } else return {min(a.l, b.l), a.r + b.r - 1, a.ct + b.ct}; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("", "r", stdin); // freopen("", "w", stdout); cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') v.push_back(i); else if (s[i] == ',') mp[v.back()] = i; else if (s[i] == ')') v.pop_back(); } state a = recurse(0, s.size() - 1); cout << a.r - a.l + 1; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:64:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for (int i = 0; i < s.size(); 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...