이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define en cin.close();return 0;
#define pb push_back
#define fi first//printf("%lli\n",cur);
#define se second//scanf("%lli",&n);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string str;
int go2(int l, int r)
{
if(l==r)
return 0;
int op = 0, pos = l+4;
while(1)
{
if(str[pos]=='(')
op++;
else if(str[pos]==')')
op--;
else if(str[pos]==','&&op==0)
break;
pos++;
}
int l1 = go2(l+4,pos-1), r1 = go2(pos+1,r-1);
if(str[l+1]=='i')
return min(l1,0)+min(r1,0)-1;
else
return max(l1,0)+max(r1,0)+1;
}
int main()
{
fio
// ifstream cin("in.in");
cin >> str;
int n = 0;
for(auto x:str)
n+=(x=='?');
cout << n-abs(go2(0,str.size()-1));
// cin.close();
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... |