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 <bits/stdc++.h>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
/*
#define cin fin
#define cout fout
string __fname = ""; ifstream fin(__fname + ".in"); ofstream fout(__fname + ".out");
*/
#define ull unsigned long long
#define ll long long
#define int long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
int mod = 1e9 + 7;
const int inf = 1e18;
const int N = 1e6 + 10;
int n;
pii fun(){
char a, b, c, d;
cin >> a;
if(a == '?'){
n++;
return {0, 0};
}
cin >> b >> c >> d;
bool mx = b == 'a';
pii p1 = fun();
cin >> d;
pii p2 = fun();
cin >> d;
if(mx)
return {p1.first + p2.first + 1, min(p1.second, p2.second)};
return {min(p1.first, p2.first), p1.second + p2.second + 1};
}
void solve(){
pii p = fun();
cout << n - p.first - p.second << '\n';
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
// cin >> t;
while(t--)
solve();
return 0;
}
# | 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... |