답안 #1036927

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036927 2024-07-27T19:49:39 Z vjudge1 Homework (CEOI22_homework) C++17
0 / 100
1000 ms 14144 KB
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define x first
    #define y second
    string s;
    ll n=0;
    pair<ll,ll> sol(ll a, ll b)
    {
        if(a==b) return {1,n};
        ll temp=a+4;
        ll pl=true;ll c1=0;
        while(pl)
        {
            c1+=(s[temp]=='(');
            c1-=(s[temp]==')');
            if(c1==0&&s[temp]==',') break;
            temp++;
        }
        pair<ll,ll> o1=sol(a+4,temp-1);
        pair<ll,ll> o2=sol(temp+1,b-1);
        if(s[a+2]=='n')
        {
            ll temp1=0;
            if(s[a+4]!='?'&&s[a+6]=='n'&&s[temp+1]!='?'&&s[temp+3]=='n') temp1++;
            return {min(o1.x,o2.x),min(o1.y,o2.y)-1-temp1};
        }
        else
        {
            ll temp1=0;
            if(s[a+4]!='?'&&s[a+6]=='x'&&s[temp+1]!='?'&&s[temp+3]=='x') temp1++;
            return {max(o1.x,o2.x)+1+temp1,max(o1.y,o2.y)};
        }
    }
    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);cout.tie(0);
        cin>>s;
        for(auto i:s)n+=(i=='?');
        pair<ll,ll> asd=sol(0,s.size()-1);
        cout<<(asd.y-asd.x+1);
        return 0;
    }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1047 ms 14144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -