| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 666527 | Farbod | Homework (CEOI22_homework) | C++17 | 430 ms | 190148 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 <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)
| # | 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... | ||||
