Submission #666527

#TimeUsernameProblemLanguageResultExecution timeMemory
666527FarbodHomework (CEOI22_homework)C++17
100 / 100
430 ms190148 KiB
#include <iostream> #include <vector> #include <map> using namespace std; #define pi pair <int, int> #define pii pair <pi, int> #define F first #define S second string s; vector <int> v; map <int, int> mp; pii f(int l, int r) { if (l == r) return {{1, 1}, 1}; int d = mp[l + 3]; pii a = f(l + 4, d - 1), b = f(d + 1, r - 1); bool t = (s[l + 2] == 'x'); if (t) return {{a.F.F + b.F.F, max(a.S + b.F.S, b.S + a.F.S)}, a.S + b.S}; return {{min(a.F.F, b.F.F), a.F.S + b.F.S - 1}, a.S + b.S}; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 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(); } pii a = f(0, s.size() - 1); cout << a.F.S - a.F.F + 1; return 0; }

Compilation message (stderr)

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