Submission #772714

# Submission time Handle Problem Language Result Execution time Memory
772714 2023-07-04T10:40:57 Z Valters07 Homework (CEOI22_homework) C++14
13 / 100
127 ms 115624 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());
const int N = 1e6+5;
vector<int> mid[N];
string str;
int go2(int l, int r, int op)
{
    if(l==r)
        return 0;
    int pos = mid[op].back();
    mid[op].pop_back();
    int l1 = go2(l+4,pos-1,op+1), r1 = go2(pos+1,r-1,op+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, op = 0;
    for(int i = str.size()-1;i>=0;i--)
    {
        n+=(str[i]=='?');
        op+=(str[i]==')')-(str[i]=='(');
        if(str[i]==',')
            mid[op].pb(i);
    }
    cout << n-abs(go2(0,str.size()-1,1));
//    cin.close();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 109248 KB Output is correct
2 Correct 112 ms 115388 KB Output is correct
3 Correct 115 ms 115356 KB Output is correct
4 Correct 116 ms 115340 KB Output is correct
5 Correct 109 ms 115432 KB Output is correct
6 Correct 114 ms 115424 KB Output is correct
7 Correct 111 ms 115452 KB Output is correct
8 Correct 127 ms 115416 KB Output is correct
9 Correct 111 ms 115340 KB Output is correct
10 Correct 114 ms 115432 KB Output is correct
11 Correct 113 ms 115432 KB Output is correct
12 Correct 116 ms 115624 KB Output is correct
13 Correct 12 ms 23816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23804 KB Output isn't correct
2 Halted 0 ms 0 KB -