Submission #791713

#TimeUsernameProblemLanguageResultExecution timeMemory
791713enerelt14Homework (CEOI22_homework)C++14
53 / 100
1042 ms14028 KiB
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> #define ff first #define ss second using namespace std; string s; pair<int, int> solve(int l, int r) { if(l == r) return {0, 0}; int cnt = 0, x; if(s[4 + l] != 'm') x = 5 + l; else { for(int i = 7 + l; i < r; i++) { if(s[i] == '(') cnt++; if(s[i] == ')') cnt--; if(!cnt) { x = i + 1; break; } } } pair<int, int> a = solve(4 + l, x - 1), b = solve(x + 1, r - 1); if(s[1 + l] == 'i') return {a.ff + b.ff + 1, min(a.ss, b.ss)}; else return {min(a.ff, b.ff), a.ss + b.ss + 1}; return {0, 0}; } int main() { ios::sync_with_stdio(0);cin.tie(0); cin >> s; int n = (int)s.size() / 7 + 1; pair<int, int> ans = solve(0, (int)s.size() - 1); cout << n - ans.ff - ans.ss; }

Compilation message (stderr)

Main.cpp: In function 'std::pair<int, int> solve(int, int)':
Main.cpp:37:39: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |  pair<int, int> a = solve(4 + l, x - 1), b = solve(x + 1, r - 1);
      |                                       ^
#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...