提交记录 3571


用户 题目 状态 得分 用时 内存 语言 代码长度
1124828077 noi17b. 【NOI2017】蚯蚓排队 Runtime Error 0 30.352 ms 10700 KB C++ 2.59 KB
提交时间 评测时间
2018-07-16 14:37:55 2020-07-31 21:19:47
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int k=50,mod=998244353;
int n,m,len,y[10000002],t[8][20000002];
long long ans;
char ch[10000002];
typedef struct{
    int w,las,nex;
}P;
P p[200002];
char buf[100000],*pp1=buf,*pp2=buf;
inline char nc()
{
    return pp1==pp2 && (pp2=(pp1=buf)+fread(buf,1,100000,stdin),pp1==pp2) ? EOF : *pp1++;
}
inline int read()
{ 
    char ch;int x=0;bool f=0;
    while((ch=nc())<48)if(ch==45)break;
    if(ch==45)f=1;else x=ch-48;
    while((ch=nc())>=48)x=(x<<1)+(x<<3)+ch-48;
    return f ? -x : x;
}
int main()
{
    n=read();m=read();
    for (int i=1;i<=n;i++)
    {
        p[i].w=read();p[i].las=p[i].nex=-1;
        if (!t[p[i].w][0])t[p[i].w][0]=++len;
        t[0][t[p[i].w][0]]++;
    }
    while(m--)
    {
        int u;
        u=read();
        if (u==1)
        {
            int a,b,c,root;bool u;
            a=read();b=read();
            p[a].nex=b;p[b].las=a;
            for (int i=a;i!=-1;i=p[i].las)
            {
                c=u=root=0;
                for (int j=i;c<k&&j!=-1;j=p[j].nex)
                {
                    if (!t[p[j].w][root])
                    {
                        t[p[j].w][root]=++len;
                        if (t[7][root]==-1 || !t[p[j].w][t[7][root]])
                        t[7][len]=-1;
                        else t[7][len]=t[p[j].w][t[7][root]];
                    }
                    root=t[p[j].w][root];
                    if (j==b)u=1;t[0][root]+=u;
                    c++;
                }
                if (!u)break;
            }
        }
        else if (u==2)
        {
            int a,b,c,root;bool u;
            a=read();b=p[a].nex;
            for (int i=a;i!=-1;i=p[i].las)
            {
                c=u=0;root=0;
                for (int j=i;c<k&&j!=-1;j=p[j].nex)
                {
                    root=t[p[j].w][root];
                    if (j==b)u=1;t[0][root]-=u;
                    c++;
                }
                if (!u)break;
            }
            p[a].nex=p[b].las=-1;
        }
        else
        {
            int a,l,root=0;ans=0;
            scanf("%s",ch);a=read();l=strlen(ch);
            for (int i=0;i<a;i++)
            {
                root=t[ch[i]-48][root];if (!root)goto ccj;
            }
            ans=t[0][root];
            for (int i=a;i<l;i++)
            {
                root=t[7][root];if (root<0){ans=0;goto ccj;}
                root=t[ch[i]-48][root];if (!root){ans=0;goto ccj;}
                ans=ans*t[0][root]%mod;
            }
            ccj:printf("%lld\n",ans);
        }
    }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #110.74 us32 KBRuntime ErrorScore: 0

Testcase #216.85 us40 KBRuntime ErrorScore: 0

Testcase #354.81 us76 KBRuntime ErrorScore: 0

Testcase #499.22 us72 KBRuntime ErrorScore: 0

Testcase #5162.23 us84 KBRuntime ErrorScore: 0

Testcase #6807.7 us744 KBRuntime ErrorScore: 0

Testcase #75.933 ms720 KBRuntime ErrorScore: 0

Testcase #86.744 ms2 MB + 912 KBRuntime ErrorScore: 0

Testcase #97.425 ms3 MB + 476 KBRuntime ErrorScore: 0

Testcase #106.901 ms3 MB + 228 KBRuntime ErrorScore: 0

Testcase #117.362 ms3 MB + 588 KBRuntime ErrorScore: 0

Testcase #121.947 ms1 MB + 304 KBRuntime ErrorScore: 0

Testcase #139.841 ms1 MB + 280 KBRuntime ErrorScore: 0

Testcase #1414.008 ms5 MB + 344 KBRuntime ErrorScore: 0

Testcase #1512.742 ms4 MB + 676 KBRuntime ErrorScore: 0

Testcase #1611.285 ms3 MB + 736 KBRuntime ErrorScore: 0

Testcase #1716.759 ms7 MB + 568 KBRuntime ErrorScore: 0

Testcase #18865.46 us2 MB + 444 KBRuntime ErrorScore: 0

Testcase #19860.15 us2 MB + 436 KBRuntime ErrorScore: 0

Testcase #204.893 ms2 MB + 468 KBRuntime ErrorScore: 0

Testcase #2122.192 ms2 MB + 424 KBRuntime ErrorScore: 0

Testcase #2229.457 ms9 MB + 752 KBRuntime ErrorScore: 0

Testcase #2320.608 ms5 MB + 64 KBRuntime ErrorScore: 0

Testcase #2430.352 ms10 MB + 460 KBRuntime ErrorScore: 0

Testcase #2523.624 ms6 MB + 556 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-18 08:49:41 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠