# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791713 | enerelt14 | Homework (CEOI22_homework) | C++14 | 1042 ms | 14028 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |