提交记录 3568


用户 题目 状态 得分 用时 内存 语言 代码长度
1124828077 noi17b. 【NOI2017】蚯蚓排队 Accepted 100 584.255 ms 95800 KB C++ 2.47 KB
提交时间 评测时间
2018-07-16 14:35:32 2020-07-31 21:19:41
#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];
int read()
{
    int data=0,w=1; char ch=0;
    while(ch!='-' && (ch<'0' || ch>'9')) ch=getchar();
    if(ch=='-'){w=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){data=data*10+ch-'0';ch=getchar();}
    return data*w;
}
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 #1267.39 us32 KBAcceptedScore: 4

Testcase #225.98 us40 KBAcceptedScore: 4

Testcase #38.779 ms64 KBAcceptedScore: 4

Testcase #4183.8 us96 KBAcceptedScore: 4

Testcase #55.982 ms124 KBAcceptedScore: 4

Testcase #638.998 ms26 MB + 604 KBAcceptedScore: 4

Testcase #719.038 ms624 KBAcceptedScore: 4

Testcase #829.551 ms22 MB + 568 KBAcceptedScore: 4

Testcase #940.797 ms28 MB + 240 KBAcceptedScore: 4

Testcase #1099.857 ms24 MB + 352 KBAcceptedScore: 4

Testcase #11131.755 ms35 MB + 312 KBAcceptedScore: 4

Testcase #1251.353 ms31 MB + 244 KBAcceptedScore: 4

Testcase #1340.374 ms1 MB + 192 KBAcceptedScore: 4

Testcase #1463.276 ms42 MB + 48 KBAcceptedScore: 4

Testcase #1573.311 ms45 MB + 596 KBAcceptedScore: 4

Testcase #16237.897 ms45 MB + 556 KBAcceptedScore: 4

Testcase #17277.741 ms55 MB + 32 KBAcceptedScore: 4

Testcase #18254.339 ms85 MB + 124 KBAcceptedScore: 4

Testcase #19279.844 ms93 MB + 484 KBAcceptedScore: 4

Testcase #2059.656 ms23 MB + 216 KBAcceptedScore: 4

Testcase #2183.805 ms2 MB + 344 KBAcceptedScore: 4

Testcase #22145.769 ms77 MB + 944 KBAcceptedScore: 4

Testcase #23153.836 ms79 MB + 424 KBAcceptedScore: 4

Testcase #24540.288 ms84 MB + 896 KBAcceptedScore: 4

Testcase #25584.255 ms93 MB + 568 KBAcceptedScore: 4


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:34:13 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠