QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#182916#6750. CalculateKewuRE 0ms0kbC++111.3kb2023-09-18 19:02:502023-09-18 19:02:51

Judging History

你现在查看的是最新测评结果

  • [2023-09-18 19:02:51]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-09-18 19:02:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N=5e3+10;

char Map[N];

int main()
{
    gets(Map+1);int n=strlen(Map+1);
    int ans=0;
    for(int i=1;i<=n;++i)
    {
        if(Map[i]!='?'&&(Map[i]<'0'||Map[i]>'9'))  continue;
        int flag=1;
        stack<char> t;
        for(int j=1;j<i;++j)
        {
            if(Map[j]!='?'&&(Map[j]<'0'||Map[j]>'9'))
            {
                if(Map[j]=='+') continue;
                if(Map[j]=='-')
                {
                    if(!t.empty()&&t.top()=='-')    t.pop(),flag=-flag;
                    else    t.push('-'),flag=-flag;
                }
                if(Map[j]=='(')
                    t.push('(');
                if(Map[j]==')')
                {
                    while(t.top()!='(')
                    {
                        if(t.top()=='-')    flag=-flag;
                        t.pop();
                    }
                    t.pop();
                    if(!t.empty()&&t.top()=='-')    t.pop(),flag=-flag;
                }
            }
        }
        if(Map[i]=='?')
        {
            if(flag==1)
                ans+=9;
        }
        else    ans+=flag*(Map[i]-'0');
    }
    cout<<ans<<endl;
    system("pause");
    return 0;
}
/*
-(?+7)-(?-3)
-4
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

?+?

output:

18

result: