Submission #772689

# Submission time Handle Problem Language Result Execution time Memory
772689 2023-07-04T10:28:50 Z Valters07 Homework (CEOI22_homework) C++14
0 / 100
1000 ms 10652 KB
#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
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 10652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -