喵啊啊QAQ本地运行和提交不同

P3952 [NOIP2017 提高组] 时间复杂度

Atri_Lobato @ 2024-08-20 19:51:02

82分 wa on #6 #10 6数据:

2
54 O(n^9)
F a 8 n
F b 60 62
F c 20 n
F d 81 n
F e 70 n
F f 78 n
E
E
E
E
E
E
F a 76 n
F b 34 n
F c 16 n
F d 2 n
F e 5 n
F f 87 n
F g 8 n
F h 3 n
F i n 17
E
E
E
E
E
E
E
E
E
F a 90 n
F b 79 n
F c 24 n
F d 58 n
F e 58 n
F f 61 32
F g 5 n
F h 80 n
F i 54 n
F j 5 n
F k 79 97
F l 61 86
E
E
E
E
E
E
E
E
E
E
E
E
42 O(n^4)
F a 38 n
F b 7 n
F c n n
F d 79 n
F e 20 n
F f 99 7
F g 68 n
F h 74 n
F i 24 n
E
E
E
E
E
E
E
E
E
F a 10 n
F b 65 n
F c 45 91
F d n 7
F e 44 n
E
E
E
E
E
F a 75 n
F b 55 n
F c 82 39
F d 59 n
F e 38 n
F f 36 50
F g 40 n
E
E
E
E
E
E
E
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[10005];
char s2[10005];
int stack1=0;//几层循环 
bool ne[10005];
int reboot;
char nn[10005];
int maxn=0;
int ans;
bool name[50];
int l;
int q;
int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        scanf("%d%s",&l,s);
        bool flag=0;
        stack1=0;
        ans=0;
        bool ef=1;
        maxn=0;
        memset(nn,0,sizeof(nn));
        memset(ne,0,sizeof(ne));
        memset(name,0,sizeof(name));
        for(q=1;q<=l;q++)
        {
            char type[5],x[5],y[5]; 
            char newn[5];
            scanf("%s",type);

            if(type[0]=='E')
            {
                if(flag)
                continue;
                name[nn[stack1]-'a']=0;
                if(stack1==reboot)
                {
                    ef=1;
                }
                if(ne[stack1])
                {
                    maxn--;
                    ne[stack1]=0;
                }
                stack1--;
            }
            else
            {
                scanf("%s%s%s",newn,x,y);
                if(flag)
                continue;
                stack1++;
                if(name[newn[0]-'a'])
                {
                    flag=1;
                    continue;
                }
                nn[stack1]=newn[0];
                name[newn[0]-'a']=1;
                if(ef==0)
                continue;
                if(x[0]<='9'&&x[0]>='0'&&y[0]<='9'&&y[0]>='0')
                {
                    if(x<=y)//o1
                    {

                    }
                    else//no
                    {
                        ef=0;
                        reboot=stack1;
                    }
                }
                else if(x[0]=='n'&&y[0]=='n')//o1
                {

                }
                else if(x[0]=='n')//no
                {
                    ef=0;
                    reboot=stack1;
                }
                else//on
                {
//                  cout<<">_<";
                    ne[stack1]=1;
                    maxn+=1;
                    ans=max(ans,maxn);
                }
            }
        }
        if(flag==1||stack1!=0)
        {
            printf("ERR\n");
            continue;
        }
//      cout<<q<<endl;
        if(s[2]=='1')
        {
            if(ans>=1)
            {
                printf("No\n");
            }
            else
            {
                printf("Yes\n");
            }
            continue;
        }
        int O=0;
//      cout<<"O("<<ans<<")\n";
        if(s[2]=='1')
        {
            if(ans==0)
            printf("Yes\n");
            else
            printf("No\n");
            continue;
        }
        for(int q=4;s[q]!=')';q++)
        {
            O*=10;
            O+=int(s[q]-'0');
        }
//      cout<<"O("<<O<<")\n\n";
        if(O==ans)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}

|