提交记录 7991


用户 题目 状态 得分 用时 内存 语言 代码长度
Jouna_Kasa_Hasinele noip17b. 【NOIP2017】时间复杂度 Accepted 100 89.24 us 20 KB C++11 2.58 KB
提交时间 评测时间
2019-01-26 21:43:17 2020-08-01 01:11:24
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=105,S=15,M=27,INF=101;
int t,n,top,ind,now,ans,k;
char c[S],s[N][S],buf[S];
int st[N],d[M],dfn[N],stf[N],mo[N];
int l[N],r[N];
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        scanf("%s",c);
        k=0;
        if(c[2]=='n')
            for(int i=4;c[i]!=')';i++)
                k=k*10+c[i]-'0';
        memset(s,0,sizeof(s));
        for(int i=1;i<=n;i++)
        {
            scanf("%s",buf);
            strcat(s[i]+1,buf);
            if(buf[0]=='F')
            {
                scanf("%s",buf);
                strcat(s[i]+1," ");
                strcat(s[i]+1,buf);
                scanf("%s",buf);
                l[i]=0;
                if(buf[0]=='n')
                    l[i]=INF;
                else
                    for(int j=0;buf[j]!='\0';j++)
                        l[i]=l[i]*10+buf[j]-'0';
                scanf("%s",buf);
                r[i]=0;
                if(buf[0]=='n')
                    r[i]=INF;
                else
                    for(int j=0;buf[j]!='\0';j++)
                        r[i]=r[i]*10+buf[j]-'0';
            }
        }
        bool ok=1;
        top=ind=0;
        memset(d,0,sizeof(d));
        memset(dfn,0,sizeof(dfn));
        for(int i=1;i<=n&&ok;i++)
        {
            dfn[i]=++ind;
            if(s[i][1]=='F')
            {
                if(d[s[i][3]-'a'])
                    ok=0;
                d[s[i][3]-'a']++;
                st[++top]=s[i][3];
                stf[top]=ind;
            }
            else
            {
                d[st[top]-'a']--;
                mo[stf[top]]=ind;
                top--;
                if(top<0)
                {
                    ok=0;
                    top=0;
                }
            }
        }
        if(top>0)
            ok=0;
        if(!ok)
        {
            printf("ERR\n");
            continue;
        }
        top=now=ans=0;
        for(int i=1;i<=n;i++)
        {
            if(s[i][1]=='F')
            {
                if(l[i]<=r[i])
                {
                    if(r[i]==INF&&l[i]!=INF)
                        now++;
                    st[++top]=(r[i]==INF&&l[i]!=INF);
                    ans=max(ans,now);
                }
                else
                    i=mo[i];
            }
            else
                if(st[top--])
                    now--;
        }
        if(ans==0&&c[3]=='1')
            printf("Yes\n");
        else if(ans==k)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #113.83 us20 KBAcceptedScore: 10

Testcase #213.44 us20 KBAcceptedScore: 10

Testcase #317.92 us20 KBAcceptedScore: 10

Testcase #425.89 us20 KBAcceptedScore: 10

Testcase #535.59 us20 KBAcceptedScore: 10

Testcase #621.02 us20 KBAcceptedScore: 10

Testcase #734.87 us20 KBAcceptedScore: 10

Testcase #861.95 us20 KBAcceptedScore: 10

Testcase #944.28 us20 KBAcceptedScore: 10

Testcase #1089.24 us20 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2024-05-06 20:32:30 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用